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/project/xaction/PhabricatorProjectWorkboardTransaction.php
src/applications/project/xaction/PhabricatorProjectWorkboardTransaction.php
<?php final class PhabricatorProjectWorkboardTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:hasworkboard'; public function generateOldValue($object) { return (int)$object->getHasWorkboard(); } public function generateNewValue($object, $value) { return (int)$value; } public function applyInternalEffects($object, $value) { $object->setHasWorkboard($value); } public function getTitle() { $new = $this->getNewValue(); if ($new) { return pht( '%s enabled the workboard for this project.', $this->renderAuthor()); } else { return pht( '%s disabled the workboard for this project.', $this->renderAuthor()); } } public function shouldHide() { 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/xaction/PhabricatorProjectLockTransaction.php
src/applications/project/xaction/PhabricatorProjectLockTransaction.php
<?php final class PhabricatorProjectLockTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:locked'; public function generateOldValue($object) { return (int)$object->getIsMembershipLocked(); } public function applyInternalEffects($object, $value) { $object->setIsMembershipLocked($value); } public function getTitle() { $new = $this->getNewValue(); if ($new) { return pht( "%s locked this project's membership.", $this->renderAuthor()); } else { return pht( "%s unlocked this project's membership.", $this->renderAuthor()); } } public function getTitleForFeed() { $new = $this->getNewValue(); if ($new) { return pht( '%s locked %s membership.', $this->renderAuthor(), $this->renderObject()); } else { return pht( '%s unlocked %s membership.', $this->renderAuthor(), $this->renderObject()); } } public function getIcon() { $new = $this->getNewValue(); if ($new) { return 'fa-lock'; } else { return 'fa-unlock'; } } public function validateTransactions($object, array $xactions) { if ($xactions) { $this->requireApplicationCapability( ProjectCanLockProjectsCapability::CAPABILITY); } return array(); } }
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/PhabricatorProjectWorkboardBackgroundTransaction.php
src/applications/project/xaction/PhabricatorProjectWorkboardBackgroundTransaction.php
<?php final class PhabricatorProjectWorkboardBackgroundTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:background'; public function generateOldValue($object) { return $object->getWorkboardBackgroundColor(); } public function applyInternalEffects($object, $value) { $object->setWorkboardBackgroundColor($value); } public function getTitle() { return pht( '%s changed the background color of the project workboard.', $this->renderAuthor()); } public function shouldHide() { 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/xaction/PhabricatorProjectSortTransaction.php
src/applications/project/xaction/PhabricatorProjectSortTransaction.php
<?php final class PhabricatorProjectSortTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:sort'; public function generateOldValue($object) { return $object->getDefaultWorkboardSort(); } public function applyInternalEffects($object, $value) { $object->setDefaultWorkboardSort($value); } public function getTitle() { return pht( '%s changed the default sort order for the project workboard.', $this->renderAuthor()); } public function shouldHide() { 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/xaction/PhabricatorProjectMilestoneTransaction.php
src/applications/project/xaction/PhabricatorProjectMilestoneTransaction.php
<?php final class PhabricatorProjectMilestoneTransaction extends PhabricatorProjectTypeTransaction { const TRANSACTIONTYPE = 'project:milestone'; public function generateOldValue($object) { return null; } public function applyInternalEffects($object, $value) { $parent_phid = $value; $project = id(new PhabricatorProjectQuery()) ->setViewer($this->getActor()) ->withPHIDs(array($parent_phid)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); $object->attachParentProject($project); $number = $object->getParentProject()->loadNextMilestoneNumber(); $object->setMilestoneNumber($number); $object->setParentProjectPHID($value); } }
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/PhabricatorProjectParentTransaction.php
src/applications/project/xaction/PhabricatorProjectParentTransaction.php
<?php final class PhabricatorProjectParentTransaction extends PhabricatorProjectTypeTransaction { const TRANSACTIONTYPE = 'project:parent'; public function generateOldValue($object) { return null; } public function applyInternalEffects($object, $value) { $parent_phid = $value; $project = id(new PhabricatorProjectQuery()) ->setViewer($this->getActor()) ->withPHIDs(array($parent_phid)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); $object->attachParentProject($project); $object->setParentProjectPHID($value); } }
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/PhabricatorProjectStatusTransaction.php
src/applications/project/xaction/PhabricatorProjectStatusTransaction.php
<?php final class PhabricatorProjectStatusTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:status'; public function generateOldValue($object) { return $object->getStatus(); } public function applyInternalEffects($object, $value) { $object->setStatus($value); } public function getTitle() { $old = $this->getOldValue(); if ($old == 0) { return pht( '%s archived this project.', $this->renderAuthor()); } else { return pht( '%s activated this project.', $this->renderAuthor()); } } public function getTitleForFeed() { $old = $this->getOldValue(); if ($old == 0) { return pht( '%s archived %s.', $this->renderAuthor(), $this->renderObject()); } else { return pht( '%s activated %s.', $this->renderAuthor(), $this->renderObject()); } } public function getColor() { $old = $this->getOldValue(); if ($old == 0) { return 'red'; } else { return 'green'; } } public function getIcon() { $old = $this->getOldValue(); if ($old == 0) { return 'fa-ban'; } else { return 'fa-check'; } } }
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/PhabricatorProjectFilterTransaction.php
src/applications/project/xaction/PhabricatorProjectFilterTransaction.php
<?php final class PhabricatorProjectFilterTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:filter'; public function generateOldValue($object) { return $object->getDefaultWorkboardFilter(); } public function applyInternalEffects($object, $value) { $object->setDefaultWorkboardFilter($value); } public function getTitle() { return pht( '%s changed the default filter for the project workboard.', $this->renderAuthor()); } public function shouldHide() { 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/xaction/PhabricatorProjectTransactionType.php
src/applications/project/xaction/PhabricatorProjectTransactionType.php
<?php abstract class PhabricatorProjectTransactionType extends PhabricatorModularTransactionType {}
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/PhabricatorProjectTypeTransaction.php
src/applications/project/xaction/PhabricatorProjectTypeTransaction.php
<?php abstract class PhabricatorProjectTypeTransaction extends PhabricatorProjectTransactionType { public function validateTransactions($object, array $xactions) { $errors = array(); if (!$xactions) { return $errors; } $xaction = last($xactions); $parent_phid = $xaction->getNewValue(); if (!$parent_phid) { return $errors; } if (!$this->getEditor()->getIsNewObject()) { $errors[] = $this->newInvalidError( pht( 'You can only set a parent or milestone project when creating a '. 'project for the first time.')); return $errors; } $projects = id(new PhabricatorProjectQuery()) ->setViewer($this->getActor()) ->withPHIDs(array($parent_phid)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->execute(); if (!$projects) { $errors[] = $this->newInvalidError( pht( 'Parent or milestone project PHID ("%s") must be the PHID of a '. 'valid, visible project which you have permission to edit.', $parent_phid)); return $errors; } $project = head($projects); if ($project->isMilestone()) { $errors[] = $this->newInvalidError( pht( 'Parent or milestone project PHID ("%s") must not be a '. 'milestone. Milestones may not have subprojects or milestones.', $parent_phid)); return $errors; } $limit = PhabricatorProject::getProjectDepthLimit(); if ($project->getProjectDepth() >= ($limit - 1)) { $errors[] = $this->newInvalidError( pht( 'You can not create a subproject or milestone under this parent '. 'because it would nest projects too deeply. The maximum '. 'nesting depth of projects is %s.', new PhutilNumber($limit))); return $errors; } return $errors; } }
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/PhabricatorProjectImageTransaction.php
src/applications/project/xaction/PhabricatorProjectImageTransaction.php
<?php final class PhabricatorProjectImageTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:image'; public function generateOldValue($object) { return $object->getProfileImagePHID(); } public function applyInternalEffects($object, $value) { $object->setProfileImagePHID($value); } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); // TODO: Some day, it would be nice to show the images. if (!$old) { return pht( "%s set this project's image to %s.", $this->renderAuthor(), $this->renderNewHandle()); } else if (!$new) { return pht( "%s removed this project's image.", $this->renderAuthor()); } else { return pht( "%s updated this project's image from %s to %s.", $this->renderAuthor(), $this->renderOldHandle(), $this->renderNewHandle()); } } public function getTitleForFeed() { $old = $this->getOldValue(); $new = $this->getNewValue(); // TODO: Some day, it would be nice to show the images. if (!$old) { return pht( '%s set the image for %s to %s.', $this->renderAuthor(), $this->renderObject(), $this->renderNewHandle()); } else if (!$new) { return pht( '%s removed the image for %s.', $this->renderAuthor(), $this->renderObject()); } else { return pht( '%s updated the image for %s from %s to %s.', $this->renderAuthor(), $this->renderObject(), $this->renderOldHandle(), $this->renderNewHandle()); } } public function getIcon() { return 'fa-photo'; } public function extractFilePHIDs($object, $value) { if ($value) { return array($value); } return array(); } public function validateTransactions($object, array $xactions) { $errors = array(); $viewer = $this->getActor(); foreach ($xactions as $xaction) { $file_phid = $xaction->getNewValue(); // Only validate if file was uploaded if ($file_phid) { $file = id(new PhabricatorFileQuery()) ->setViewer($viewer) ->withPHIDs(array($file_phid)) ->executeOne(); if (!$file) { $errors[] = $this->newInvalidError( pht('"%s" is not a valid file PHID.', $file_phid)); } else { if (!$file->isViewableImage()) { $mime_type = $file->getMimeType(); $errors[] = $this->newInvalidError( pht('File mime type of "%s" is not a valid viewable image.', $mime_type)); } } } } return $errors; } }
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/PhabricatorProjectColorTransaction.php
src/applications/project/xaction/PhabricatorProjectColorTransaction.php
<?php final class PhabricatorProjectColorTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:color'; public function generateOldValue($object) { return $object->getColor(); } public function applyInternalEffects($object, $value) { $object->setColor($value); } public function getTitle() { $new = $this->getNewValue(); return pht( "%s set this project's color to %s.", $this->renderAuthor(), $this->renderValue(PHUITagView::getShadeName($new))); } public function getTitleForFeed() { $new = $this->getNewValue(); return pht( '%s set the color for %s to %s.', $this->renderAuthor(), $this->renderObject(), $this->renderValue(PHUITagView::getShadeName($new))); } }
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/PhabricatorProjectNameTransaction.php
src/applications/project/xaction/PhabricatorProjectNameTransaction.php
<?php final class PhabricatorProjectNameTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:name'; public function generateOldValue($object) { return $object->getName(); } public function applyInternalEffects($object, $value) { $object->setName($value); if (!$this->getEditor()->getIsMilestone()) { $object->setPrimarySlug(PhabricatorSlug::normalizeProjectSlug($value)); } } public function applyExternalEffects($object, $value) { $old = $this->getOldValue(); // First, add the old name as a secondary slug; this is helpful // for renames and generally a good thing to do. if (!$this->getEditor()->getIsMilestone()) { if ($old !== null) { $this->getEditor()->addSlug($object, $old, false); } $this->getEditor()->addSlug($object, $value, false); } return; } public function getTitle() { $old = $this->getOldValue(); if ($old === null) { return pht( '%s created this project.', $this->renderAuthor()); } else { return pht( '%s renamed this project from %s to %s.', $this->renderAuthor(), $this->renderOldValue(), $this->renderNewValue()); } } public function getTitleForFeed() { $old = $this->getOldValue(); if ($old === null) { return pht( '%s created %s.', $this->renderAuthor(), $this->renderObject()); } else { return pht( '%s renamed %s from %s to %s.', $this->renderAuthor(), $this->renderObject(), $this->renderOldValue(), $this->renderNewValue()); } } public function validateTransactions($object, array $xactions) { $errors = array(); if ($this->isEmptyTextTransaction($object->getName(), $xactions)) { $errors[] = $this->newRequiredError(pht('Projects must have a name.')); } $max_length = $object->getColumnMaximumByteLength('name'); foreach ($xactions as $xaction) { $new_value = $xaction->getNewValue(); $new_length = strlen($new_value); if ($new_length > $max_length) { $errors[] = $this->newInvalidError( pht( 'Project names must not be longer than %s character(s).', new PhutilNumber($max_length))); } } if ($this->getEditor()->getIsMilestone() || !$xactions) { return $errors; } $name = last($xactions)->getNewValue(); if (!PhabricatorSlug::isValidProjectSlug($name)) { $errors[] = $this->newInvalidError( pht('Project names must contain at least one letter or number.')); } $slug = PhabricatorSlug::normalizeProjectSlug($name); $slug_used_already = id(new PhabricatorProjectSlug()) ->loadOneWhere('slug = %s', $slug); if ($slug_used_already && $slug_used_already->getProjectPHID() != $object->getPHID()) { $errors[] = $this->newInvalidError( pht( 'Project name generates the same hashtag ("%s") as another '. 'existing project. Choose a unique name.', '#'.$slug)); } return $errors; } }
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/PhabricatorProjectSlugsTransaction.php
src/applications/project/xaction/PhabricatorProjectSlugsTransaction.php
<?php final class PhabricatorProjectSlugsTransaction extends PhabricatorProjectTransactionType { const TRANSACTIONTYPE = 'project:slugs'; public function generateOldValue($object) { $slugs = $object->getSlugs(); $slugs = mpull($slugs, 'getSlug', 'getSlug'); unset($slugs[$object->getPrimarySlug()]); return array_keys($slugs); } public function generateNewValue($object, $value) { return $this->getEditor()->normalizeSlugs($value); } public function applyInternalEffects($object, $value) { return; } public function applyExternalEffects($object, $value) { $old = $this->getOldValue(); $new = $value; $add = array_diff($new, $old); $rem = array_diff($old, $new); foreach ($add as $slug) { $this->getEditor()->addSlug($object, $slug, true); } $this->getEditor()->removeSlugs($object, $rem); } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); $add = array_diff($new, $old); $rem = array_diff($old, $new); $add = $this->renderHashtags($add); $rem = $this->renderHashtags($rem); if ($add && $rem) { return pht( '%s changed project hashtag(s), added %d: %s; removed %d: %s.', $this->renderAuthor(), count($add), $this->renderValueList($add), count($rem), $this->renderValueList($rem)); } else if ($add) { return pht( '%s added %d project hashtag(s): %s.', $this->renderAuthor(), count($add), $this->renderValueList($add)); } else if ($rem) { return pht( '%s removed %d project hashtag(s): %s.', $this->renderAuthor(), count($rem), $this->renderValueList($rem)); } } public function getTitleForFeed() { $old = $this->getOldValue(); $new = $this->getNewValue(); $add = array_diff($new, $old); $rem = array_diff($old, $new); $add = $this->renderHashtags($add); $rem = $this->renderHashtags($rem); if ($add && $rem) { return pht( '%s changed %s hashtag(s), added %d: %s; removed %d: %s.', $this->renderAuthor(), $this->renderObject(), count($add), $this->renderValueList($add), count($rem), $this->renderValueList($rem)); } else if ($add) { return pht( '%s added %d %s hashtag(s): %s.', $this->renderAuthor(), count($add), $this->renderObject(), $this->renderValueList($add)); } else if ($rem) { return pht( '%s removed %d %s hashtag(s): %s.', $this->renderAuthor(), count($rem), $this->renderObject(), $this->renderValueList($rem)); } } public function getIcon() { return 'fa-tag'; } public function validateTransactions($object, array $xactions) { $errors = array(); if (!$xactions) { return $errors; } $slug_xaction = last($xactions); $new = $slug_xaction->getNewValue(); $invalid = array(); foreach ($new as $slug) { if (!PhabricatorSlug::isValidProjectSlug($slug)) { $invalid[] = $slug; } } if ($invalid) { $errors[] = $this->newInvalidError( pht( 'Hashtags must contain at least one letter or number. %s '. 'project hashtag(s) are invalid: %s.', phutil_count($invalid), implode(', ', $invalid))); return $errors; } $new = $this->getEditor()->normalizeSlugs($new); if ($new) { $slugs_used_already = id(new PhabricatorProjectSlug()) ->loadAllWhere('slug IN (%Ls)', $new); } else { // The project doesn't have any extra slugs. $slugs_used_already = array(); } $slugs_used_already = mgroup($slugs_used_already, 'getProjectPHID'); foreach ($slugs_used_already as $project_phid => $used_slugs) { if ($project_phid == $object->getPHID()) { continue; } $used_slug_strs = mpull($used_slugs, 'getSlug'); $errors[] = $this->newInvalidError( pht( '%s project hashtag(s) are already used by other projects: %s.', phutil_count($used_slug_strs), implode(', ', $used_slug_strs))); } return $errors; } private function renderHashtags(array $tags) { $result = array(); foreach ($tags as $tag) { $result[] = '#'.$tag; } return $result; } }
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/column/PhabricatorProjectColumnTriggerTransaction.php
src/applications/project/xaction/column/PhabricatorProjectColumnTriggerTransaction.php
<?php final class PhabricatorProjectColumnTriggerTransaction extends PhabricatorProjectColumnTransactionType { const TRANSACTIONTYPE = 'trigger'; public function generateOldValue($object) { return $object->getTriggerPHID(); } public function applyInternalEffects($object, $value) { $object->setTriggerPHID($value); } public function applyExternalEffects($object, $value) { // After we change the trigger attached to a column, update the search // indexes for the old and new triggers so we update the usage index. $old = $this->getOldValue(); $new = $this->getNewValue(); $column_phids = array(); if ($old) { $column_phids[] = $old; } if ($new) { $column_phids[] = $new; } foreach ($column_phids as $phid) { PhabricatorSearchWorker::queueDocumentForIndexing($phid); } } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); if (!$old) { return pht( '%s set the column trigger to %s.', $this->renderAuthor(), $this->renderNewHandle()); } else if (!$new) { return pht( '%s removed the trigger for this column (was %s).', $this->renderAuthor(), $this->renderOldHandle()); } else { return pht( '%s changed the trigger for this column from %s to %s.', $this->renderAuthor(), $this->renderOldHandle(), $this->renderNewHandle()); } } public function validateTransactions($object, array $xactions) { $actor = $this->getActor(); $errors = array(); foreach ($xactions as $xaction) { $trigger_phid = $xaction->getNewValue(); // You can always remove a trigger. if (!$trigger_phid) { continue; } // You can't put a trigger on a column that can't have triggers, like // a backlog column or a proxy column. if (!$object->canHaveTrigger()) { $errors[] = $this->newInvalidError( pht('This column can not have a trigger.'), $xaction); continue; } $trigger = id(new PhabricatorProjectTriggerQuery()) ->setViewer($actor) ->withPHIDs(array($trigger_phid)) ->execute(); if (!$trigger) { $errors[] = $this->newInvalidError( pht( 'Trigger "%s" is not a valid trigger, or you do not have '. 'permission to view it.', $trigger_phid), $xaction); continue; } } return $errors; } }
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/column/PhabricatorProjectColumnTransactionType.php
src/applications/project/xaction/column/PhabricatorProjectColumnTransactionType.php
<?php abstract class PhabricatorProjectColumnTransactionType extends PhabricatorModularTransactionType {}
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/column/PhabricatorProjectColumnNameTransaction.php
src/applications/project/xaction/column/PhabricatorProjectColumnNameTransaction.php
<?php final class PhabricatorProjectColumnNameTransaction extends PhabricatorProjectColumnTransactionType { const TRANSACTIONTYPE = 'project:col:name'; public function generateOldValue($object) { return $object->getName(); } public function applyInternalEffects($object, $value) { $object->setName($value); } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); if (!strlen($old)) { return pht( '%s named this column %s.', $this->renderAuthor(), $this->renderNewValue()); } else if (strlen($new)) { return pht( '%s renamed this column from %s to %s.', $this->renderAuthor(), $this->renderOldValue(), $this->renderNewValue()); } else { return pht( '%s removed the custom name of this column.', $this->renderAuthor()); } } public function validateTransactions($object, array $xactions) { $errors = array(); if ($this->isEmptyTextTransaction($object->getName(), $xactions)) { // The default "Backlog" column is allowed to be unnamed, which // means we use the default name. // Proxy columns can't have a name, so don't raise an error here. if (!$object->isDefaultColumn() && !$object->getProxy()) { $errors[] = $this->newRequiredError( pht('Columns must have a name.')); } } $max_length = $object->getColumnMaximumByteLength('name'); foreach ($xactions as $xaction) { $new_value = $xaction->getNewValue(); $new_length = strlen($new_value); if ($new_length > $max_length) { $errors[] = $this->newInvalidError( pht( 'Column names must not be longer than %s characters.', new PhutilNumber($max_length)), $xaction); } } return $errors; } }
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/column/PhabricatorProjectColumnLimitTransaction.php
src/applications/project/xaction/column/PhabricatorProjectColumnLimitTransaction.php
<?php final class PhabricatorProjectColumnLimitTransaction extends PhabricatorProjectColumnTransactionType { const TRANSACTIONTYPE = 'project:col:limit'; public function generateOldValue($object) { return $object->getPointLimit(); } public function generateNewValue($object, $value) { if (strlen($value)) { return (int)$value; } else { return null; } } public function applyInternalEffects($object, $value) { $object->setPointLimit($value); } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); if (!$old) { return pht( '%s set the point limit for this column to %s.', $this->renderAuthor(), $this->renderNewValue()); } else if (!$new) { return pht( '%s removed the point limit for this column.', $this->renderAuthor()); } else { return pht( '%s changed the point limit for this column from %s to %s.', $this->renderAuthor(), $this->renderOldValue(), $this->renderNewValue()); } } public function validateTransactions($object, array $xactions) { $errors = array(); foreach ($xactions as $xaction) { $value = $xaction->getNewValue(); if (strlen($value) && !preg_match('/^\d+\z/', $value)) { $errors[] = $this->newInvalidError( pht( 'Column point limit must either be empty or a nonnegative '. 'integer.'), $xaction); } } return $errors; } }
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/column/PhabricatorProjectColumnStatusTransaction.php
src/applications/project/xaction/column/PhabricatorProjectColumnStatusTransaction.php
<?php final class PhabricatorProjectColumnStatusTransaction extends PhabricatorProjectColumnTransactionType { const TRANSACTIONTYPE = 'project:col:status'; public function generateOldValue($object) { return $object->getStatus(); } public function applyInternalEffects($object, $value) { $object->setStatus($value); } public function applyExternalEffects($object, $value) { // Update the trigger usage index, which cares about whether columns are // active or not. $trigger_phid = $object->getTriggerPHID(); if ($trigger_phid) { PhabricatorSearchWorker::queueDocumentForIndexing($trigger_phid); } } public function getTitle() { $new = $this->getNewValue(); switch ($new) { case PhabricatorProjectColumn::STATUS_ACTIVE: return pht( '%s unhid this column.', $this->renderAuthor()); case PhabricatorProjectColumn::STATUS_HIDDEN: return pht( '%s hid this column.', $this->renderAuthor()); } } public function validateTransactions($object, array $xactions) { $errors = array(); $map = array( PhabricatorProjectColumn::STATUS_ACTIVE, PhabricatorProjectColumn::STATUS_HIDDEN, ); $map = array_fuse($map); foreach ($xactions as $xaction) { $value = $xaction->getNewValue(); if (!isset($map[$value])) { $errors[] = $this->newInvalidError( pht( 'Column status "%s" is unrecognized, valid statuses are: %s.', $value, implode(', ', array_keys($map))), $xaction); } } return $errors; } }
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/trigger/PhabricatorProjectTriggerNameTransaction.php
src/applications/project/xaction/trigger/PhabricatorProjectTriggerNameTransaction.php
<?php final class PhabricatorProjectTriggerNameTransaction extends PhabricatorProjectTriggerTransactionType { const TRANSACTIONTYPE = 'name'; public function generateOldValue($object) { return $object->getName(); } public function applyInternalEffects($object, $value) { $object->setName($value); } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); if (strlen($old) && strlen($new)) { return pht( '%s renamed this trigger from %s to %s.', $this->renderAuthor(), $this->renderOldValue(), $this->renderNewValue()); } else if (strlen($new)) { return pht( '%s named this trigger %s.', $this->renderAuthor(), $this->renderNewValue()); } else { return pht( '%s stripped the name %s from this trigger.', $this->renderAuthor(), $this->renderOldValue()); } } public function validateTransactions($object, array $xactions) { $errors = array(); $max_length = $object->getColumnMaximumByteLength('name'); foreach ($xactions as $xaction) { $new_value = $xaction->getNewValue(); $new_length = strlen($new_value); if ($new_length > $max_length) { $errors[] = $this->newInvalidError( pht( 'Trigger names must not be longer than %s characters.', new PhutilNumber($max_length)), $xaction); } } return $errors; } }
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/trigger/PhabricatorProjectTriggerRulesetTransaction.php
src/applications/project/xaction/trigger/PhabricatorProjectTriggerRulesetTransaction.php
<?php final class PhabricatorProjectTriggerRulesetTransaction extends PhabricatorProjectTriggerTransactionType { const TRANSACTIONTYPE = 'ruleset'; public function generateOldValue($object) { return $object->getRuleset(); } public function applyInternalEffects($object, $value) { $object->setRuleset($value); } public function getTitle() { return pht( '%s updated the ruleset for this trigger.', $this->renderAuthor()); } public function validateTransactions($object, array $xactions) { $actor = $this->getActor(); $errors = array(); foreach ($xactions as $xaction) { $ruleset = $xaction->getNewValue(); try { $rules = PhabricatorProjectTrigger::newTriggerRulesFromRuleSpecifications( $ruleset, $allow_invalid = false, $actor); } catch (PhabricatorProjectTriggerCorruptionException $ex) { $errors[] = $this->newInvalidError( pht( 'Ruleset specification is not valid. %s', $ex->getMessage()), $xaction); continue; } foreach ($rules as $rule) { $exception = $rule->getRuleRecordValueValidationException(); if ($exception) { $errors[] = $this->newInvalidError( pht( 'Value for "%s" rule is invalid: %s', $rule->getSelectControlName(), $exception->getMessage()), $xaction); continue; } } } return $errors; } public function hasChangeDetailView() { return true; } public function newChangeDetailView() { $viewer = $this->getViewer(); $old = $this->getOldValue(); $new = $this->getNewValue(); $json = new PhutilJSON(); $old_json = $json->encodeAsList($old); $new_json = $json->encodeAsList($new); return id(new PhabricatorApplicationTransactionTextDiffDetailView()) ->setViewer($viewer) ->setOldText($old_json) ->setNewText($new_json); } }
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/trigger/PhabricatorProjectTriggerTransactionType.php
src/applications/project/xaction/trigger/PhabricatorProjectTriggerTransactionType.php
<?php abstract class PhabricatorProjectTriggerTransactionType extends PhabricatorModularTransactionType {}
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
<?php final class PhabricatorProjectManageProfileMenuItem extends PhabricatorProfileMenuItem { const MENUITEMKEY = 'project.manage'; public function getMenuItemTypeName() { return pht('Manage Project'); } private function getDefaultName() { return pht('Manage'); } public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { $default = $this->getDefaultName(); return $this->getNameFromConfig($config, $default); } public function getMenuItemTypeIcon() { return 'fa-cog'; } public function canHideMenuItem( PhabricatorProfileMenuItemConfiguration $config) { return false; } public function canMakeDefault( PhabricatorProfileMenuItemConfiguration $config) { return true; } public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( id(new PhabricatorTextEditField()) ->setKey('name') ->setLabel(pht('Name')) ->setPlaceholder($this->getDefaultName()) ->setValue($config->getMenuItemProperty('name')), ); } protected function newMenuItemViewList( PhabricatorProfileMenuItemConfiguration $config) { $project = $config->getProfileObject(); $id = $project->getID(); $name = $this->getDisplayName($config); $icon = 'fa-gears'; $uri = "/project/manage/{$id}/"; $item = $this->newItemView() ->setURI($uri) ->setName($name) ->setIcon($icon); return array( $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/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
<?php final class PhabricatorProjectSubprojectsProfileMenuItem extends PhabricatorProfileMenuItem { const MENUITEMKEY = 'project.subprojects'; public function getMenuItemTypeName() { return pht('Project Subprojects'); } private function getDefaultName() { return pht('Subprojects'); } public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { $default = $this->getDefaultName(); return $this->getNameFromConfig($config, $default); } public function getMenuItemTypeIcon() { return 'fa-sitemap'; } public function shouldEnableForObject($object) { if ($object->isMilestone()) { return false; } return true; } public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( id(new PhabricatorTextEditField()) ->setKey('name') ->setLabel(pht('Name')) ->setPlaceholder($this->getDefaultName()) ->setValue($config->getMenuItemProperty('name')), ); } protected function newMenuItemViewList( PhabricatorProfileMenuItemConfiguration $config) { $project = $config->getProfileObject(); $id = $project->getID(); $name = $this->getDisplayName($config); $icon = 'fa-sitemap'; $uri = "/project/subprojects/{$id}/"; $item = $this->newItemView() ->setURI($uri) ->setName($name) ->setIcon($icon); return array( $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/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
<?php final class PhabricatorProjectWorkboardProfileMenuItem extends PhabricatorProfileMenuItem { const MENUITEMKEY = 'project.workboard'; public function getMenuItemTypeName() { return pht('Project Workboard'); } private function getDefaultName() { return pht('Workboard'); } public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { $default = $this->getDefaultName(); return $this->getNameFromConfig($config, $default); } public function getMenuItemTypeIcon() { return 'fa-columns'; } public function canMakeDefault( PhabricatorProfileMenuItemConfiguration $config) { return true; } public function shouldEnableForObject($object) { $viewer = $this->getViewer(); // Workboards are only available if Maniphest is installed. $class = 'PhabricatorManiphestApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return false; } return true; } public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( id(new PhabricatorTextEditField()) ->setKey('name') ->setLabel(pht('Name')) ->setPlaceholder($this->getDefaultName()) ->setValue($config->getMenuItemProperty('name')), ); } protected function newMenuItemViewList( PhabricatorProfileMenuItemConfiguration $config) { $project = $config->getProfileObject(); $id = $project->getID(); $uri = $project->getWorkboardURI(); $name = $this->getDisplayName($config); $item = $this->newItemView() ->setURI($uri) ->setName($name) ->setIcon('fa-columns'); return array( $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/menuitem/PhabricatorProjectPointsProfileMenuItem.php
src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php
<?php final class PhabricatorProjectPointsProfileMenuItem extends PhabricatorProfileMenuItem { const MENUITEMKEY = 'project.points'; public function getMenuItemTypeName() { return pht('Project Points'); } private function getDefaultName() { return pht('Points Bar'); } public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { return $this->getDefaultName(); } public function shouldEnableForObject($object) { $viewer = $this->getViewer(); // Only render this element for milestones. if (!$object->isMilestone()) { return false; } // Don't show if points aren't configured. if (!ManiphestTaskPoints::getIsEnabled()) { return false; } // Points are only available if Maniphest is installed. $class = 'PhabricatorManiphestApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return false; } return true; } public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( id(new PhabricatorInstructionsEditField()) ->setValue( pht( 'This is a progress bar which shows how many points of work '. 'are complete within the milestone. It has no configurable '. 'settings.')), ); } protected function newMenuItemViewList( PhabricatorProfileMenuItemConfiguration $config) { $viewer = $this->getViewer(); $project = $config->getProfileObject(); $limit = 250; $tasks = id(new ManiphestTaskQuery()) ->setViewer($viewer) ->withEdgeLogicPHIDs( PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, PhabricatorQueryConstraint::OPERATOR_AND, array($project->getPHID())) ->setLimit($limit + 1) ->execute(); $error = array(); if (count($tasks) > $limit) { $error[] = pht( 'Too many tasks (%s).', new PhutilNumber($limit)); } if (!$tasks) { $error[] = pht('This milestone has no tasks.'); } $statuses = array(); $points_done = 0; $points_total = 0; $no_points = 0; foreach ($tasks as $task) { $points = $task->getPoints(); if ($points === null) { $no_points++; continue; } if (!$points) { continue; } $status = $task->getStatus(); if (empty($statuses[$status])) { $statuses[$status] = 0; } $statuses[$status] += $points; if (ManiphestTaskStatus::isClosedStatus($status)) { $points_done += $points; } $points_total += $points; } if ($no_points == count($tasks)) { $error[] = pht('No tasks have points assigned.'); } if (!$points_total) { $error[] = pht('No tasks have positive points.'); } $label = pht( '%s of %s %s', new PhutilNumber($points_done), new PhutilNumber($points_total), ManiphestTaskPoints::getPointsLabel()); $bar = id(new PHUISegmentBarView()) ->setLabel($label); $map = ManiphestTaskStatus::getTaskStatusMap(); $statuses = array_select_keys($statuses, array_keys($map)); foreach ($statuses as $status => $points) { if (!$points) { continue; } if (!ManiphestTaskStatus::isClosedStatus($status)) { continue; } $color = ManiphestTaskStatus::getStatusColor($status); if (!$color) { $color = 'sky'; } $tooltip = pht( '%s %s', new PhutilNumber($points), ManiphestTaskStatus::getTaskStatusName($status)); $bar->newSegment() ->setWidth($points / $points_total) ->setColor($color) ->setTooltip($tooltip); } if ($error) { $bar->setLabel(head($error)); } $bar = phutil_tag( 'div', array( 'class' => 'phui-profile-segment-bar', ), $bar); $item = $this->newItemView(); $item->newProgressBar($bar); return array( $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/menuitem/PhabricatorProjectReportsProfileMenuItem.php
src/applications/project/menuitem/PhabricatorProjectReportsProfileMenuItem.php
<?php final class PhabricatorProjectReportsProfileMenuItem extends PhabricatorProfileMenuItem { const MENUITEMKEY = 'project.reports'; public function getMenuItemTypeName() { return pht('Project Reports'); } private function getDefaultName() { return pht('Reports (Prototype)'); } public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { $default = $this->getDefaultName(); return $this->getNameFromConfig($config, $default); } public function getMenuItemTypeIcon() { return 'fa-area-chart'; } public function canMakeDefault( PhabricatorProfileMenuItemConfiguration $config) { return true; } public function shouldEnableForObject($object) { $viewer = $this->getViewer(); if (!PhabricatorEnv::getEnvConfig('phabricator.show-prototypes')) { return false; } $class = 'PhabricatorManiphestApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return false; } $class = 'PhabricatorFactApplication'; if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { return false; } return true; } public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( id(new PhabricatorTextEditField()) ->setKey('name') ->setLabel(pht('Name')) ->setPlaceholder($this->getDefaultName()) ->setValue($config->getMenuItemProperty('name')), ); } protected function newMenuItemViewList( PhabricatorProfileMenuItemConfiguration $config) { $project = $config->getProfileObject(); $id = $project->getID(); $uri = $project->getReportsURI(); $name = $this->getDisplayName($config); $item = $this->newItemView() ->setURI($uri) ->setName($name) ->setIcon('fa-area-chart'); return array( $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/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
<?php final class PhabricatorProjectDetailsProfileMenuItem extends PhabricatorProfileMenuItem { const MENUITEMKEY = 'project.details'; public function getMenuItemTypeName() { return pht('Project Details'); } private function getDefaultName() { return pht('Project Details'); } public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { $default = $this->getDefaultName(); return $this->getNameFromConfig($config, $default); } public function getMenuItemTypeIcon() { return 'fa-file-text-o'; } public function canHideMenuItem( PhabricatorProfileMenuItemConfiguration $config) { return false; } public function canMakeDefault( PhabricatorProfileMenuItemConfiguration $config) { return true; } public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( id(new PhabricatorTextEditField()) ->setKey('name') ->setLabel(pht('Name')) ->setPlaceholder($this->getDefaultName()) ->setValue($config->getMenuItemProperty('name')), ); } protected function newMenuItemViewList( PhabricatorProfileMenuItemConfiguration $config) { $project = $config->getProfileObject(); $id = $project->getID(); $name = $project->getName(); $icon = $project->getDisplayIconIcon(); $uri = "/project/profile/{$id}/"; $item = $this->newItemView() ->setURI($uri) ->setName($name) ->setIcon($icon); return array( $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/menuitem/PhabricatorProjectMembersProfileMenuItem.php
src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
<?php final class PhabricatorProjectMembersProfileMenuItem extends PhabricatorProfileMenuItem { const MENUITEMKEY = 'project.members'; public function getMenuItemTypeName() { return pht('Project Members'); } private function getDefaultName() { return pht('Members'); } public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { $default = $this->getDefaultName(); return $this->getNameFromConfig($config, $default); } public function getMenuItemTypeIcon() { return 'fa-users'; } public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( id(new PhabricatorTextEditField()) ->setKey('name') ->setLabel(pht('Name')) ->setPlaceholder($this->getDefaultName()) ->setValue($config->getMenuItemProperty('name')), ); } protected function newMenuItemViewList( PhabricatorProfileMenuItemConfiguration $config) { $project = $config->getProfileObject(); $id = $project->getID(); $name = $this->getDisplayName($config); $icon = 'fa-group'; $uri = "/project/members/{$id}/"; $item = $this->newItemView() ->setURI($uri) ->setName($name) ->setIcon($icon); return array( $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/menuitem/PhabricatorProjectPictureProfileMenuItem.php
src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php
<?php final class PhabricatorProjectPictureProfileMenuItem extends PhabricatorProfileMenuItem { const MENUITEMKEY = 'project.picture'; public function getMenuItemTypeName() { return pht('Project Picture'); } private function getDefaultName() { return pht('Project Picture'); } public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { return $this->getDefaultName(); } public function getMenuItemTypeIcon() { return 'fa-image'; } public function canHideMenuItem( PhabricatorProfileMenuItemConfiguration $config) { return false; } public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array(); } protected function newMenuItemViewList( PhabricatorProfileMenuItemConfiguration $config) { $project = $config->getProfileObject(); $picture = $project->getProfileImageURI(); $item = $this->newItemView() ->setDisabled($project->isArchived()); $item->newProfileImage($picture); return array( $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/exception/PhabricatorProjectTriggerCorruptionException.php
src/applications/project/exception/PhabricatorProjectTriggerCorruptionException.php
<?php final class PhabricatorProjectTriggerCorruptionException extends Exception {}
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/searchfield/PhabricatorProjectSearchField.php
src/applications/project/searchfield/PhabricatorProjectSearchField.php
<?php final class PhabricatorProjectSearchField extends PhabricatorSearchTokenizerField { protected function getDefaultValue() { return array(); } protected function newDatasource() { return new PhabricatorProjectLogicalDatasource(); } protected function getValueFromRequest(AphrontRequest $request, $key) { $list = $this->getListFromRequest($request, $key); $phids = array(); $slugs = array(); $project_type = PhabricatorProjectProjectPHIDType::TYPECONST; foreach ($list as $item) { $type = phid_get_type($item); if ($type == $project_type) { $phids[] = $item; } else { if (PhabricatorTypeaheadDatasource::isFunctionToken($item)) { // If this is a function, pass it through unchanged; we'll evaluate // it later. $phids[] = $item; } else { $slugs[] = $item; } } } if ($slugs) { $projects = id(new PhabricatorProjectQuery()) ->setViewer($this->getViewer()) ->withSlugs($slugs) ->execute(); foreach ($projects as $project) { $phids[] = $project->getPHID(); } $phids = array_unique($phids); } return $phids; } protected function newConduitParameterType() { return new ConduitProjectListParameterType(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/application/PhabricatorProjectApplication.php
src/applications/project/application/PhabricatorProjectApplication.php
<?php final class PhabricatorProjectApplication extends PhabricatorApplication { public function getName() { return pht('Projects'); } public function getShortDescription() { return pht('Projects, Tags, and Teams'); } public function isPinnedByDefault(PhabricatorUser $viewer) { return true; } public function getBaseURI() { return '/project/'; } public function getIcon() { return 'fa-briefcase'; } public function getFlavorText() { return pht('Group stuff into big piles.'); } public function getRemarkupRules() { return array( new ProjectRemarkupRule(), ); } public function getEventListeners() { return array( new PhabricatorProjectUIEventListener(), ); } public function getRoutes() { return array( '/project/' => array( '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorProjectListController', 'filter/(?P<filter>[^/]+)/' => 'PhabricatorProjectListController', 'archive/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectArchiveController', 'lock/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectLockController', 'members/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectMembersViewController', 'members/(?P<id>[1-9]\d*)/add/' => 'PhabricatorProjectMembersAddController', '(?P<type>members|watchers)/(?P<id>[1-9]\d*)/remove/' => 'PhabricatorProjectMembersRemoveController', 'profile/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectProfileController', 'view/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectViewController', 'picture/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectEditPictureController', $this->getEditRoutePattern('edit/') => 'PhabricatorProjectEditController', '(?P<projectID>[1-9]\d*)/item/' => $this->getProfileMenuRouting( 'PhabricatorProjectMenuItemController'), 'subprojects/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectSubprojectsController', 'board/(?P<id>[1-9]\d*)/'. '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorProjectBoardViewController', 'move/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectMoveController', 'cover/' => 'PhabricatorProjectCoverController', 'reports/(?P<projectID>[1-9]\d*)/' => 'PhabricatorProjectReportsController', 'board/(?P<projectID>[1-9]\d*)/' => array( 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorProjectColumnEditController', 'hide/(?:(?P<id>\d+)/)?' => 'PhabricatorProjectColumnHideController', 'column/(?:(?P<id>\d+)/)?' => 'PhabricatorProjectColumnDetailController', 'viewquery/(?P<columnID>\d+)/' => 'PhabricatorProjectColumnViewQueryController', 'bulk/(?P<columnID>\d+)/' => 'PhabricatorProjectColumnBulkEditController', 'bulkmove/(?P<columnID>\d+)/(?P<mode>project|column)/' => 'PhabricatorProjectColumnBulkMoveController', 'import/' => 'PhabricatorProjectBoardImportController', 'reorder/' => 'PhabricatorProjectBoardReorderController', 'disable/' => 'PhabricatorProjectBoardDisableController', 'manage/' => 'PhabricatorProjectBoardManageController', 'background/' => 'PhabricatorProjectBoardBackgroundController', 'default/(?P<target>[^/]+)/' => 'PhabricatorProjectBoardDefaultController', 'filter/(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorProjectBoardFilterController', 'reload/' => 'PhabricatorProjectBoardReloadController', ), 'column/' => array( 'remove/(?P<id>\d+)/' => 'PhabricatorProjectColumnRemoveTriggerController', ), 'trigger/' => array( $this->getQueryRoutePattern() => 'PhabricatorProjectTriggerListController', '(?P<id>[1-9]\d*)/' => 'PhabricatorProjectTriggerViewController', $this->getEditRoutePattern('edit/') => 'PhabricatorProjectTriggerEditController', ), 'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/' => 'PhabricatorProjectUpdateController', 'manage/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectManageController', '(?P<action>watch|unwatch)/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectWatchController', 'silence/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectSilenceController', 'warning/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectSubprojectWarningController', ), '/tag/' => array( '(?P<slug>[^/]+)/' => 'PhabricatorProjectViewController', '(?P<slug>[^/]+)/board/' => 'PhabricatorProjectBoardViewController', ), ); } protected function getCustomCapabilities() { return array( ProjectCreateProjectsCapability::CAPABILITY => array(), ProjectCanLockProjectsCapability::CAPABILITY => array( 'default' => PhabricatorPolicies::POLICY_ADMIN, ), ProjectDefaultViewCapability::CAPABILITY => array( 'caption' => pht('Default view policy for newly created projects.'), 'template' => PhabricatorProjectProjectPHIDType::TYPECONST, 'capability' => PhabricatorPolicyCapability::CAN_VIEW, ), ProjectDefaultEditCapability::CAPABILITY => array( 'caption' => pht('Default edit policy for newly created projects.'), 'template' => PhabricatorProjectProjectPHIDType::TYPECONST, 'capability' => PhabricatorPolicyCapability::CAN_EDIT, ), ProjectDefaultJoinCapability::CAPABILITY => array( 'caption' => pht('Default join policy for newly created projects.'), 'template' => PhabricatorProjectProjectPHIDType::TYPECONST, 'capability' => PhabricatorPolicyCapability::CAN_JOIN, ), ); } public function getApplicationSearchDocumentTypes() { return array( PhabricatorProjectProjectPHIDType::TYPECONST, ); } public function getApplicationOrder() { return 0.150; } public function getHelpDocumentationArticles(PhabricatorUser $viewer) { return array( array( 'name' => pht('Projects User Guide'), 'href' => PhabricatorEnv::getDoclink('Projects User Guide'), ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
<?php final class PhabricatorProjectCoreTestCase extends PhabricatorTestCase { protected function getPhabricatorTestCaseConfiguration() { return array( self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true, ); } public function testViewProject() { $user = $this->createUser(); $user->save(); $user2 = $this->createUser(); $user2->save(); $proj = $this->createProject($user); $proj = $this->refreshProject($proj, $user, true); $this->joinProject($proj, $user); $proj->setViewPolicy(PhabricatorPolicies::POLICY_USER); $proj->save(); $can_view = PhabricatorPolicyCapability::CAN_VIEW; // When the view policy is set to "users", any user can see the project. $this->assertTrue((bool)$this->refreshProject($proj, $user)); $this->assertTrue((bool)$this->refreshProject($proj, $user2)); // When the view policy is set to "no one", members can still see the // project. $proj->setViewPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->save(); $this->assertTrue((bool)$this->refreshProject($proj, $user)); $this->assertFalse((bool)$this->refreshProject($proj, $user2)); } public function testApplicationPolicy() { $user = $this->createUser() ->save(); $proj = $this->createProject($user); $this->assertTrue( PhabricatorPolicyFilter::hasCapability( $user, $proj, PhabricatorPolicyCapability::CAN_VIEW)); // This object is visible so its handle should load normally. $handle = id(new PhabricatorHandleQuery()) ->setViewer($user) ->withPHIDs(array($proj->getPHID())) ->executeOne(); $this->assertEqual($proj->getPHID(), $handle->getPHID()); // Change the "Can Use Application" policy for Projecs to "No One". This // should cause filtering checks to fail even when they are executed // directly rather than via a Query. $env = PhabricatorEnv::beginScopedEnv(); $env->overrideEnvConfig( 'phabricator.application-settings', array( 'PHID-APPS-PhabricatorProjectApplication' => array( 'policy' => array( 'view' => PhabricatorPolicies::POLICY_NOONE, ), ), )); // Application visibility is cached because it does not normally change // over the course of a single request. Drop the cache so the next filter // test uses the new visibility. PhabricatorCaches::destroyRequestCache(); $this->assertFalse( PhabricatorPolicyFilter::hasCapability( $user, $proj, PhabricatorPolicyCapability::CAN_VIEW)); // We should still be able to load a handle for the project, even if we // can not see the application. $handle = id(new PhabricatorHandleQuery()) ->setViewer($user) ->withPHIDs(array($proj->getPHID())) ->executeOne(); // The handle should load... $this->assertEqual($proj->getPHID(), $handle->getPHID()); // ...but be policy filtered. $this->assertTrue($handle->getPolicyFiltered()); unset($env); } public function testIsViewerMemberOrWatcher() { $user1 = $this->createUser() ->save(); $user2 = $this->createUser() ->save(); $user3 = $this->createUser() ->save(); $proj1 = $this->createProject($user1); $proj1 = $this->refreshProject($proj1, $user1); $this->joinProject($proj1, $user1); $this->joinProject($proj1, $user3); $this->watchProject($proj1, $user3); $proj1 = $this->refreshProject($proj1, $user1); $this->assertTrue($proj1->isUserMember($user1->getPHID())); $proj1 = $this->refreshProject($proj1, $user1, false, true); $this->assertTrue($proj1->isUserMember($user1->getPHID())); $this->assertFalse($proj1->isUserWatcher($user1->getPHID())); $proj1 = $this->refreshProject($proj1, $user1, true, false); $this->assertTrue($proj1->isUserMember($user1->getPHID())); $this->assertFalse($proj1->isUserMember($user2->getPHID())); $this->assertTrue($proj1->isUserMember($user3->getPHID())); $proj1 = $this->refreshProject($proj1, $user1, true, true); $this->assertTrue($proj1->isUserMember($user1->getPHID())); $this->assertFalse($proj1->isUserMember($user2->getPHID())); $this->assertTrue($proj1->isUserMember($user3->getPHID())); $this->assertFalse($proj1->isUserWatcher($user1->getPHID())); $this->assertFalse($proj1->isUserWatcher($user2->getPHID())); $this->assertTrue($proj1->isUserWatcher($user3->getPHID())); } public function testEditProject() { $user = $this->createUser(); $user->save(); $user->setAllowInlineCacheGeneration(true); $proj = $this->createProject($user); // When edit and view policies are set to "user", anyone can edit. $proj->setViewPolicy(PhabricatorPolicies::POLICY_USER); $proj->setEditPolicy(PhabricatorPolicies::POLICY_USER); $proj->save(); $this->assertTrue($this->attemptProjectEdit($proj, $user)); // When edit policy is set to "no one", no one can edit. $proj->setEditPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->save(); $caught = null; try { $this->attemptProjectEdit($proj, $user); } catch (Exception $ex) { $caught = $ex; } $this->assertTrue($caught instanceof Exception); } public function testAncestorMembers() { $user1 = $this->createUser(); $user1->save(); $user2 = $this->createUser(); $user2->save(); $parent = $this->createProject($user1); $child = $this->createProject($user1, $parent); $this->joinProject($child, $user1); $this->joinProject($child, $user2); $project = id(new PhabricatorProjectQuery()) ->setViewer($user1) ->withPHIDs(array($child->getPHID())) ->needAncestorMembers(true) ->executeOne(); $members = array_fuse($project->getParentProject()->getMemberPHIDs()); ksort($members); $expect = array_fuse( array( $user1->getPHID(), $user2->getPHID(), )); ksort($expect); $this->assertEqual($expect, $members); } public function testAncestryQueries() { $user = $this->createUser(); $user->save(); $ancestor = $this->createProject($user); $parent = $this->createProject($user, $ancestor); $child = $this->createProject($user, $parent); $projects = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withAncestorProjectPHIDs(array($ancestor->getPHID())) ->execute(); $this->assertEqual(2, count($projects)); $projects = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withParentProjectPHIDs(array($ancestor->getPHID())) ->execute(); $this->assertEqual(1, count($projects)); $this->assertEqual( $parent->getPHID(), head($projects)->getPHID()); $projects = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withAncestorProjectPHIDs(array($ancestor->getPHID())) ->withDepthBetween(2, null) ->execute(); $this->assertEqual(1, count($projects)); $this->assertEqual( $child->getPHID(), head($projects)->getPHID()); $parent2 = $this->createProject($user, $ancestor); $child2 = $this->createProject($user, $parent2); $grandchild2 = $this->createProject($user, $child2); $projects = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withAncestorProjectPHIDs(array($ancestor->getPHID())) ->execute(); $this->assertEqual(5, count($projects)); $projects = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withParentProjectPHIDs(array($ancestor->getPHID())) ->execute(); $this->assertEqual(2, count($projects)); $projects = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withAncestorProjectPHIDs(array($ancestor->getPHID())) ->withDepthBetween(2, null) ->execute(); $this->assertEqual(3, count($projects)); $projects = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withAncestorProjectPHIDs(array($ancestor->getPHID())) ->withDepthBetween(3, null) ->execute(); $this->assertEqual(1, count($projects)); $projects = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withPHIDs( array( $child->getPHID(), $grandchild2->getPHID(), )) ->execute(); $this->assertEqual(2, count($projects)); } public function testMemberMaterialization() { $material_type = PhabricatorProjectMaterializedMemberEdgeType::EDGECONST; $user = $this->createUser(); $user->save(); $parent = $this->createProject($user); $child = $this->createProject($user, $parent); $this->joinProject($child, $user); $parent_material = PhabricatorEdgeQuery::loadDestinationPHIDs( $parent->getPHID(), $material_type); $this->assertEqual( array($user->getPHID()), $parent_material); } public function testMilestones() { $user = $this->createUser(); $user->save(); $parent = $this->createProject($user); $m1 = $this->createProject($user, $parent, true); $m2 = $this->createProject($user, $parent, true); $m3 = $this->createProject($user, $parent, true); $this->assertEqual(1, $m1->getMilestoneNumber()); $this->assertEqual(2, $m2->getMilestoneNumber()); $this->assertEqual(3, $m3->getMilestoneNumber()); } public function testMilestoneMembership() { $user = $this->createUser(); $user->save(); $parent = $this->createProject($user); $milestone = $this->createProject($user, $parent, true); $this->joinProject($parent, $user); $milestone = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withPHIDs(array($milestone->getPHID())) ->executeOne(); $this->assertTrue($milestone->isUserMember($user->getPHID())); $milestone = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withPHIDs(array($milestone->getPHID())) ->needMembers(true) ->executeOne(); $this->assertEqual( array($user->getPHID()), $milestone->getMemberPHIDs()); } public function testSameSlugAsName() { // It should be OK to type the primary hashtag into "additional hashtags", // even if the primary hashtag doesn't exist yet because you're creating // or renaming the project. $user = $this->createUser(); $user->save(); $project = $this->createProject($user); // In this first case, set the name and slugs at the same time. $name = 'slugproject'; $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectNameTransaction::TRANSACTIONTYPE) ->setNewValue($name); $this->applyTransactions($project, $user, $xactions); $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE) ->setNewValue(array($name)); $this->applyTransactions($project, $user, $xactions); $project = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withPHIDs(array($project->getPHID())) ->needSlugs(true) ->executeOne(); $slugs = $project->getSlugs(); $slugs = mpull($slugs, 'getSlug'); $this->assertTrue(in_array($name, $slugs)); // In this second case, set the name first and then the slugs separately. $name2 = 'slugproject2'; $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectNameTransaction::TRANSACTIONTYPE) ->setNewValue($name2); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE) ->setNewValue(array($name2)); $this->applyTransactions($project, $user, $xactions); $project = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withPHIDs(array($project->getPHID())) ->needSlugs(true) ->executeOne(); $slugs = $project->getSlugs(); $slugs = mpull($slugs, 'getSlug'); $this->assertTrue(in_array($name2, $slugs)); } public function testDuplicateSlugs() { // Creating a project with multiple duplicate slugs should succeed. $user = $this->createUser(); $user->save(); $project = $this->createProject($user); $input = 'duplicate'; $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE) ->setNewValue(array($input, $input)); $this->applyTransactions($project, $user, $xactions); $project = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withPHIDs(array($project->getPHID())) ->needSlugs(true) ->executeOne(); $slugs = $project->getSlugs(); $slugs = mpull($slugs, 'getSlug'); $this->assertTrue(in_array($input, $slugs)); } public function testNormalizeSlugs() { // When a user creates a project with slug "XxX360n0sc0perXxX", normalize // it before writing it. $user = $this->createUser(); $user->save(); $project = $this->createProject($user); $input = 'NoRmAlIzE'; $expect = 'normalize'; $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE) ->setNewValue(array($input)); $this->applyTransactions($project, $user, $xactions); $project = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withPHIDs(array($project->getPHID())) ->needSlugs(true) ->executeOne(); $slugs = $project->getSlugs(); $slugs = mpull($slugs, 'getSlug'); $this->assertTrue(in_array($expect, $slugs)); // If another user tries to add the same slug in denormalized form, it // should be caught and fail, even though the database version of the slug // is normalized. $project2 = $this->createProject($user); $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE) ->setNewValue(array($input)); $caught = null; try { $this->applyTransactions($project2, $user, $xactions); } catch (PhabricatorApplicationTransactionValidationException $ex) { $caught = $ex; } $this->assertTrue((bool)$caught); } public function testProjectMembersVisibility() { // This is primarily testing that you can create a project and set the // visibility or edit policy to "Project Members" immediately. $user1 = $this->createUser(); $user1->save(); $user2 = $this->createUser(); $user2->save(); $project = PhabricatorProject::initializeNewProject($user1); $name = pht('Test Project %d', mt_rand()); $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectNameTransaction::TRANSACTIONTYPE) ->setNewValue($name); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) ->setNewValue( id(new PhabricatorProjectMembersPolicyRule()) ->getObjectPolicyFullKey()); $edge_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $edge_type) ->setNewValue( array( '=' => array($user1->getPHID() => $user1->getPHID()), )); $this->applyTransactions($project, $user1, $xactions); $this->assertTrue((bool)$this->refreshProject($project, $user1)); $this->assertFalse((bool)$this->refreshProject($project, $user2)); $this->leaveProject($project, $user1); $this->assertFalse((bool)$this->refreshProject($project, $user1)); } public function testParentProject() { $user = $this->createUser(); $user->save(); $parent = $this->createProject($user); $child = $this->createProject($user, $parent); $this->assertTrue(true); $child = $this->refreshProject($child, $user); $this->assertEqual( $parent->getPHID(), $child->getParentProject()->getPHID()); $this->assertEqual(1, (int)$child->getProjectDepth()); $this->assertFalse( $child->isUserMember($user->getPHID())); $this->assertFalse( $child->getParentProject()->isUserMember($user->getPHID())); $this->joinProject($child, $user); $child = $this->refreshProject($child, $user); $this->assertTrue( $child->isUserMember($user->getPHID())); $this->assertTrue( $child->getParentProject()->isUserMember($user->getPHID())); // Test that hiding a parent hides the child. $user2 = $this->createUser(); $user2->save(); // Second user can see the project for now. $this->assertTrue((bool)$this->refreshProject($child, $user2)); // Hide the parent. $this->setViewPolicy($parent, $user, $user->getPHID()); // First user (who can see the parent because they are a member of // the child) can see the project. $this->assertTrue((bool)$this->refreshProject($child, $user)); // Second user can not, because they can't see the parent. $this->assertFalse((bool)$this->refreshProject($child, $user2)); } public function testSlugMaps() { // When querying by slugs, slugs should be normalized and the mapping // should be reported correctly. $user = $this->createUser(); $user->save(); $name = 'queryslugproject'; $name2 = 'QUERYslugPROJECT'; $slug = 'queryslugextra'; $slug2 = 'QuErYSlUgExTrA'; $project = PhabricatorProject::initializeNewProject($user); $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectNameTransaction::TRANSACTIONTYPE) ->setNewValue($name); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE) ->setNewValue(array($slug)); $this->applyTransactions($project, $user, $xactions); $project_query = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withSlugs(array($name)); $project_query->execute(); $map = $project_query->getSlugMap(); $this->assertEqual( array( $name => $project->getPHID(), ), ipull($map, 'projectPHID')); $project_query = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withSlugs(array($slug)); $project_query->execute(); $map = $project_query->getSlugMap(); $this->assertEqual( array( $slug => $project->getPHID(), ), ipull($map, 'projectPHID')); $project_query = id(new PhabricatorProjectQuery()) ->setViewer($user) ->withSlugs(array($name, $slug, $name2, $slug2)); $project_query->execute(); $map = $project_query->getSlugMap(); $expect = array( $name => $project->getPHID(), $slug => $project->getPHID(), $name2 => $project->getPHID(), $slug2 => $project->getPHID(), ); $actual = ipull($map, 'projectPHID'); ksort($expect); ksort($actual); $this->assertEqual($expect, $actual); $expect = array( $name => $name, $slug => $slug, $name2 => $name, $slug2 => $slug, ); $actual = ipull($map, 'slug'); ksort($expect); ksort($actual); $this->assertEqual($expect, $actual); } public function testJoinLeaveProject() { $user = $this->createUser(); $user->save(); $proj = $this->createProjectWithNewAuthor(); $proj = $this->refreshProject($proj, $user, true); $this->assertTrue( (bool)$proj, pht( 'Assumption that projects are default visible '. 'to any user when created.')); $this->assertFalse( $proj->isUserMember($user->getPHID()), pht('Arbitrary user not member of project.')); // Join the project. $this->joinProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); $this->assertTrue((bool)$proj); $this->assertTrue( $proj->isUserMember($user->getPHID()), pht('Join works.')); // Join the project again. $this->joinProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); $this->assertTrue((bool)$proj); $this->assertTrue( $proj->isUserMember($user->getPHID()), pht('Joining an already-joined project is a no-op.')); // Leave the project. $this->leaveProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); $this->assertTrue((bool)$proj); $this->assertFalse( $proj->isUserMember($user->getPHID()), pht('Leave works.')); // Leave the project again. $this->leaveProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); $this->assertTrue((bool)$proj); $this->assertFalse( $proj->isUserMember($user->getPHID()), pht('Leaving an already-left project is a no-op.')); // If a user can't edit or join a project, joining fails. $proj->setEditPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->setJoinPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->save(); $proj = $this->refreshProject($proj, $user, true); $caught = null; try { $this->joinProject($proj, $user); } catch (Exception $ex) { $caught = $ex; } $this->assertTrue($ex instanceof Exception); // If a user can edit a project, they can join. $proj->setEditPolicy(PhabricatorPolicies::POLICY_USER); $proj->setJoinPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->save(); $proj = $this->refreshProject($proj, $user, true); $this->joinProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); $this->assertTrue( $proj->isUserMember($user->getPHID()), pht('Join allowed with edit permission.')); $this->leaveProject($proj, $user); // If a user can join a project, they can join, even if they can't edit. $proj->setEditPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->setJoinPolicy(PhabricatorPolicies::POLICY_USER); $proj->save(); $proj = $this->refreshProject($proj, $user, true); $this->joinProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); $this->assertTrue( $proj->isUserMember($user->getPHID()), pht('Join allowed with join permission.')); // A user can leave a project even if they can't edit it or join. $proj->setEditPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->setJoinPolicy(PhabricatorPolicies::POLICY_NOONE); $proj->save(); $proj = $this->refreshProject($proj, $user, true); $this->leaveProject($proj, $user); $proj = $this->refreshProject($proj, $user, true); $this->assertFalse( $proj->isUserMember($user->getPHID()), pht('Leave allowed without any permission.')); } public function testComplexConstraints() { $user = $this->createUser(); $user->save(); $engineering = $this->createProject($user); $engineering_scan = $this->createProject($user, $engineering); $engineering_warp = $this->createProject($user, $engineering); $exploration = $this->createProject($user); $exploration_diplomacy = $this->createProject($user, $exploration); $task_engineering = $this->newTask( $user, array($engineering), pht('Engineering Only')); $task_exploration = $this->newTask( $user, array($exploration), pht('Exploration Only')); $task_warp_explore = $this->newTask( $user, array($engineering_warp, $exploration), pht('Warp to New Planet')); $task_diplomacy_scan = $this->newTask( $user, array($engineering_scan, $exploration_diplomacy), pht('Scan Diplomat')); $task_diplomacy = $this->newTask( $user, array($exploration_diplomacy), pht('Diplomatic Meeting')); $task_warp_scan = $this->newTask( $user, array($engineering_scan, $engineering_warp), pht('Scan Warp Drives')); $this->assertQueryByProjects( $user, array( $task_engineering, $task_warp_explore, $task_diplomacy_scan, $task_warp_scan, ), array($engineering), pht('All Engineering')); $this->assertQueryByProjects( $user, array( $task_diplomacy_scan, $task_warp_scan, ), array($engineering_scan), pht('All Scan')); $this->assertQueryByProjects( $user, array( $task_warp_explore, $task_diplomacy_scan, ), array($engineering, $exploration), pht('Engineering + Exploration')); // This is testing that a query for "Parent" and "Parent > Child" works // properly. $this->assertQueryByProjects( $user, array( $task_diplomacy_scan, $task_warp_scan, ), array($engineering, $engineering_scan), pht('Engineering + Scan')); } public function testTagAncestryConflicts() { $user = $this->createUser(); $user->save(); $stonework = $this->createProject($user); $stonework_masonry = $this->createProject($user, $stonework); $stonework_sculpting = $this->createProject($user, $stonework); $task = $this->newTask($user, array()); $this->assertEqual(array(), $this->getTaskProjects($task)); $this->addProjectTags($user, $task, array($stonework->getPHID())); $this->assertEqual( array( $stonework->getPHID(), ), $this->getTaskProjects($task)); // Adding a descendant should remove the parent. $this->addProjectTags($user, $task, array($stonework_masonry->getPHID())); $this->assertEqual( array( $stonework_masonry->getPHID(), ), $this->getTaskProjects($task)); // Adding an ancestor should remove the descendant. $this->addProjectTags($user, $task, array($stonework->getPHID())); $this->assertEqual( array( $stonework->getPHID(), ), $this->getTaskProjects($task)); // Adding two tags in the same hierarchy which are not mutual ancestors // should remove the ancestor but otherwise work fine. $this->addProjectTags( $user, $task, array( $stonework_masonry->getPHID(), $stonework_sculpting->getPHID(), )); $expect = array( $stonework_masonry->getPHID(), $stonework_sculpting->getPHID(), ); sort($expect); $this->assertEqual($expect, $this->getTaskProjects($task)); } public function testTagMilestoneConflicts() { $user = $this->createUser(); $user->save(); $stonework = $this->createProject($user); $stonework_1 = $this->createProject($user, $stonework, true); $stonework_2 = $this->createProject($user, $stonework, true); $task = $this->newTask($user, array()); $this->assertEqual(array(), $this->getTaskProjects($task)); $this->addProjectTags($user, $task, array($stonework->getPHID())); $this->assertEqual( array( $stonework->getPHID(), ), $this->getTaskProjects($task)); // Adding a milesone should remove the parent. $this->addProjectTags($user, $task, array($stonework_1->getPHID())); $this->assertEqual( array( $stonework_1->getPHID(), ), $this->getTaskProjects($task)); // Adding the parent should remove the milestone. $this->addProjectTags($user, $task, array($stonework->getPHID())); $this->assertEqual( array( $stonework->getPHID(), ), $this->getTaskProjects($task)); // First, add one milestone. $this->addProjectTags($user, $task, array($stonework_1->getPHID())); // Now, adding a second milestone should remove the first milestone. $this->addProjectTags($user, $task, array($stonework_2->getPHID())); $this->assertEqual( array( $stonework_2->getPHID(), ), $this->getTaskProjects($task)); } public function testBoardMoves() { $user = $this->createUser(); $user->save(); $board = $this->createProject($user); $backlog = $this->addColumn($user, $board, 0); $column = $this->addColumn($user, $board, 1); // New tasks should appear in the backlog. $task1 = $this->newTask($user, array($board)); $expect = array( $backlog->getPHID(), ); $this->assertColumns($expect, $user, $board, $task1); // Moving a task should move it to the destination column. $this->moveToColumn($user, $board, $task1, $backlog, $column); $expect = array( $column->getPHID(), ); $this->assertColumns($expect, $user, $board, $task1); // Same thing again, with a new task. $task2 = $this->newTask($user, array($board)); $expect = array( $backlog->getPHID(), ); $this->assertColumns($expect, $user, $board, $task2); // Move it, too. $this->moveToColumn($user, $board, $task2, $backlog, $column); $expect = array( $column->getPHID(), ); $this->assertColumns($expect, $user, $board, $task2); // Now the stuff should be in the column, in order, with the more recently // moved task on top. $expect = array( $task2->getPHID(), $task1->getPHID(), ); $label = pht('Simple move'); $this->assertTasksInColumn($expect, $user, $board, $column, $label); // Move the second task after the first task. $options = array( 'afterPHIDs' => array($task1->getPHID()), ); $this->moveToColumn($user, $board, $task2, $column, $column, $options); $expect = array( $task1->getPHID(), $task2->getPHID(), ); $label = pht('With afterPHIDs'); $this->assertTasksInColumn($expect, $user, $board, $column, $label); // Move the second task before the first task. $options = array( 'beforePHIDs' => array($task1->getPHID()), ); $this->moveToColumn($user, $board, $task2, $column, $column, $options); $expect = array( $task2->getPHID(), $task1->getPHID(), ); $label = pht('With beforePHIDs'); $this->assertTasksInColumn($expect, $user, $board, $column, $label); } public function testMilestoneMoves() { $user = $this->createUser(); $user->save(); $board = $this->createProject($user); $backlog = $this->addColumn($user, $board, 0); // Create a task into the backlog. $task = $this->newTask($user, array($board)); $expect = array( $backlog->getPHID(), ); $this->assertColumns($expect, $user, $board, $task); $milestone = $this->createProject($user, $board, true); $this->addProjectTags($user, $task, array($milestone->getPHID())); // We just want the side effect of looking at the board: creation of the // milestone column. $this->loadColumns($user, $board, $task); $column = id(new PhabricatorProjectColumnQuery()) ->setViewer($user) ->withProjectPHIDs(array($board->getPHID())) ->withProxyPHIDs(array($milestone->getPHID())) ->executeOne(); $this->assertTrue((bool)$column); // Moving the task to the milestone should have moved it to the milestone // column. $expect = array( $column->getPHID(), ); $this->assertColumns($expect, $user, $board, $task); // Move the task within the "Milestone" column. This should not affect // the projects the task is tagged with. See T10912. $task_a = $task; $task_b = $this->newTask($user, array($backlog)); $this->moveToColumn($user, $board, $task_b, $backlog, $column); $a_options = array( 'beforePHID' => $task_b->getPHID(), ); $b_options = array( 'beforePHID' => $task_a->getPHID(), ); $old_projects = $this->getTaskProjects($task); // Move the target task to the top. $this->moveToColumn($user, $board, $task_a, $column, $column, $a_options); $new_projects = $this->getTaskProjects($task_a); $this->assertEqual($old_projects, $new_projects); // Move the other task. $this->moveToColumn($user, $board, $task_b, $column, $column, $b_options); $new_projects = $this->getTaskProjects($task_a); $this->assertEqual($old_projects, $new_projects); // Move the target task again. $this->moveToColumn($user, $board, $task_a, $column, $column, $a_options); $new_projects = $this->getTaskProjects($task_a); $this->assertEqual($old_projects, $new_projects);
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
true
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/policyrule/PhabricatorProjectsAllPolicyRule.php
src/applications/project/policyrule/PhabricatorProjectsAllPolicyRule.php
<?php final class PhabricatorProjectsAllPolicyRule extends PhabricatorProjectsBasePolicyRule { public function getRuleDescription() { return pht('members of all projects'); } public function applyRule( PhabricatorUser $viewer, $value, PhabricatorPolicyInterface $object) { $memberships = $this->getMemberships($viewer->getPHID()); foreach ($value as $project_phid) { if (empty($memberships[$project_phid])) { return false; } } return true; } public function getRuleOrder() { return 205; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/policyrule/PhabricatorProjectMembersPolicyRule.php
src/applications/project/policyrule/PhabricatorProjectMembersPolicyRule.php
<?php final class PhabricatorProjectMembersPolicyRule extends PhabricatorPolicyRule { private $memberships = array(); public function getRuleDescription() { return pht('members of project'); } public function willApplyRules( PhabricatorUser $viewer, array $values, array $objects) { $viewer_phid = $viewer->getPHID(); if (!$viewer_phid) { return; } if (empty($this->memberships[$viewer_phid])) { $this->memberships[$viewer_phid] = array(); } foreach ($objects as $key => $object) { $cache = $this->getTransactionHint($object); if ($cache === null) { continue; } unset($objects[$key]); if (isset($cache[$viewer_phid])) { $this->memberships[$viewer_phid][$object->getPHID()] = true; } } if (!$objects) { return; } $object_phids = mpull($objects, 'getPHID'); $edge_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs(array($viewer_phid)) ->withDestinationPHIDs($object_phids) ->withEdgeTypes( array( PhabricatorProjectMemberOfProjectEdgeType::EDGECONST, )); $edge_query->execute(); $memberships = $edge_query->getDestinationPHIDs(); if (!$memberships) { return; } $this->memberships[$viewer_phid] += array_fill_keys($memberships, true); } public function applyRule( PhabricatorUser $viewer, $value, PhabricatorPolicyInterface $object) { $viewer_phid = $viewer->getPHID(); if (!$viewer_phid) { return false; } $memberships = idx($this->memberships, $viewer_phid); return isset($memberships[$object->getPHID()]); } public function getValueControlType() { return self::CONTROL_TYPE_NONE; } public function canApplyToObject(PhabricatorPolicyInterface $object) { return ($object instanceof PhabricatorProject); } public function getObjectPolicyKey() { return 'project.members'; } public function getObjectPolicyName() { return pht('Project Members'); } public function getObjectPolicyIcon() { return 'fa-users'; } public function getPolicyExplanation() { return pht('Project members can take this action.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/policyrule/PhabricatorProjectsPolicyRule.php
src/applications/project/policyrule/PhabricatorProjectsPolicyRule.php
<?php final class PhabricatorProjectsPolicyRule extends PhabricatorProjectsBasePolicyRule { public function getRuleDescription() { return pht('members of any project'); } public function applyRule( PhabricatorUser $viewer, $value, PhabricatorPolicyInterface $object) { $memberships = $this->getMemberships($viewer->getPHID()); foreach ($value as $project_phid) { if (isset($memberships[$project_phid])) { return true; } } return false; } public function getRuleOrder() { return 200; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/policyrule/PhabricatorProjectsBasePolicyRule.php
src/applications/project/policyrule/PhabricatorProjectsBasePolicyRule.php
<?php abstract class PhabricatorProjectsBasePolicyRule extends PhabricatorPolicyRule { private $memberships = array(); protected function getMemberships($viewer_phid) { return idx($this->memberships, $viewer_phid, array()); } public function willApplyRules( PhabricatorUser $viewer, array $values, array $objects) { $values = array_unique(array_filter(array_mergev($values))); if (!$values) { return; } $projects = id(new PhabricatorProjectQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withMemberPHIDs(array($viewer->getPHID())) ->withPHIDs($values) ->execute(); foreach ($projects as $project) { $this->memberships[$viewer->getPHID()][$project->getPHID()] = true; } } public function getValueControlType() { return self::CONTROL_TYPE_TOKENIZER; } public function getValueControlTemplate() { $datasource = id(new PhabricatorProjectDatasource()) ->setParameters( array( 'policy' => 1, )); return $this->getDatasourceTemplate($datasource); } public function getValueForStorage($value) { PhutilTypeSpec::newFromString('list<string>')->check($value); return array_values($value); } public function getValueForDisplay(PhabricatorUser $viewer, $value) { $handles = id(new PhabricatorHandleQuery()) ->setViewer($viewer) ->withPHIDs($value) ->execute(); return mpull($handles, 'getFullName', 'getPHID'); } public function ruleHasEffect($value) { return (bool)$value; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/events/PhabricatorProjectUIEventListener.php
src/applications/project/events/PhabricatorProjectUIEventListener.php
<?php final class PhabricatorProjectUIEventListener extends PhabricatorEventListener { public function register() { $this->listen(PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES); } public function handleEvent(PhutilEvent $event) { $object = $event->getValue('object'); switch ($event->getType()) { case PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES: // Hacky solution so that property list view on Diffusion // commits shows build status, but not Projects, Subscriptions, // or Tokens. if ($object instanceof PhabricatorRepositoryCommit) { return; } $this->handlePropertyEvent($event); break; } } private function handlePropertyEvent($event) { $user = $event->getUser(); $object = $event->getValue('object'); if (!$object || !$object->getPHID()) { // No object, or the object has no PHID yet.. return; } if (!($object instanceof PhabricatorProjectInterface)) { // This object doesn't have projects. return; } $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $object->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); if ($project_phids) { $project_phids = array_reverse($project_phids); $handles = id(new PhabricatorHandleQuery()) ->setViewer($user) ->withPHIDs($project_phids) ->execute(); } else { $handles = array(); } // 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 ($handles && $can_appear_on_boards) { $engine = id(new PhabricatorBoardLayoutEngine()) ->setViewer($user) ->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 ($handles) { $list = id(new PHUIHandleTagListView()) ->setHandles($handles) ->setAnnotations($annotations) ->setShowHovercards(true); } else { $list = phutil_tag('em', array(), pht('None')); } $view = $event->getValue('view'); $view->addProperty(pht('Projects'), $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/lipsum/PhabricatorProjectTestDataGenerator.php
src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php
<?php final class PhabricatorProjectTestDataGenerator extends PhabricatorTestDataGenerator { const GENERATORKEY = 'projects'; public function getGeneratorName() { return pht('Projects'); } public function generateObject() { $author = $this->loadRandomUser(); $project = PhabricatorProject::initializeNewProject($author); $xactions = array(); $xactions[] = $this->newTransaction( PhabricatorProjectNameTransaction::TRANSACTIONTYPE, $this->newProjectTitle()); $xactions[] = $this->newTransaction( PhabricatorProjectStatusTransaction::TRANSACTIONTYPE, $this->newProjectStatus()); // Almost always make the author a member. $members = array(); if ($this->roll(1, 20) > 2) { $members[] = $author->getPHID(); } // Add a few other members. $size = $this->roll(2, 6, -2); for ($ii = 0; $ii < $size; $ii++) { $members[] = $this->loadRandomUser()->getPHID(); } $xactions[] = $this->newTransaction( PhabricatorTransactions::TYPE_EDGE, array( '+' => array_fuse($members), ), array( 'edge:type' => PhabricatorProjectProjectHasMemberEdgeType::EDGECONST, )); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($author) ->setContentSource($this->getLipsumContentSource()) ->setContinueOnNoEffect(true) ->applyTransactions($project, $xactions); return $project; } protected function newEmptyTransaction() { return new PhabricatorProjectTransaction(); } public function newProjectTitle() { return id(new PhabricatorProjectNameContextFreeGrammar()) ->generate(); } public function newProjectStatus() { if ($this->roll(1, 20) > 5) { return PhabricatorProjectStatus::STATUS_ACTIVE; } else { return PhabricatorProjectStatus::STATUS_ARCHIVED; } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/lipsum/PhabricatorProjectNameContextFreeGrammar.php
src/applications/project/lipsum/PhabricatorProjectNameContextFreeGrammar.php
<?php final class PhabricatorProjectNameContextFreeGrammar extends PhutilContextFreeGrammar { protected function getRules() { return array( 'start' => array( '[project]', '[project] [tion]', '[action] [project]', '[action] [project] [tion]', ), 'project' => array( 'Backend', 'Frontend', 'Web', 'Mobile', 'Tablet', 'Robot', 'NUX', 'Cars', 'Drones', 'Experience', 'Swag', 'Security', 'Culture', 'Revenue', 'Ion Cannon', 'Graphics Engine', 'Drivers', 'Audio Drivers', 'Graphics Drivers', 'Hardware', 'Data Center', '[project] [project]', '[adjective] [project]', '[adjective] [project]', ), 'adjective' => array( 'Self-Driving', 'Self-Flying', 'Self-Immolating', 'Secure', 'Insecure', 'Somewhat-Secure', 'Orbital', 'Next-Generation', ), 'tion' => array( 'Automation', 'Optimization', 'Performance', 'Improvement', 'Growth', 'Monetization', ), 'action' => array( 'Monetize', 'Monetize', 'Triage', 'Triaging', 'Automate', 'Automating', 'Improve', 'Improving', 'Optimize', 'Optimizing', 'Accelerate', 'Accelerating', ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/view/PhabricatorProjectMemberListView.php
src/applications/project/view/PhabricatorProjectMemberListView.php
<?php final class PhabricatorProjectMemberListView extends PhabricatorProjectUserListView { protected function canEditList() { $viewer = $this->getViewer(); $project = $this->getProject(); if (!$project->supportsEditMembers()) { return false; } return PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); } protected function getNoDataString() { return pht('This project does not have any members.'); } protected function getRemoveURI($phid) { $project = $this->getProject(); $id = $project->getID(); return "/project/members/{$id}/remove/?phid={$phid}"; } protected function getHeaderText() { return pht('Members'); } protected function getMembershipNote() { $viewer = $this->getViewer(); $viewer_phid = $viewer->getPHID(); $project = $this->getProject(); if (!$viewer_phid) { return null; } $note = null; if ($project->isUserMember($viewer_phid)) { $edge_type = PhabricatorProjectSilencedEdgeType::EDGECONST; $silenced = PhabricatorEdgeQuery::loadDestinationPHIDs( $project->getPHID(), $edge_type); $silenced = array_fuse($silenced); $is_silenced = isset($silenced[$viewer_phid]); if ($is_silenced) { $note = pht( 'You have disabled mail. When mail is sent to project members, '. 'you will not receive a copy.'); } else { $note = pht( 'You are a member and you will receive mail that is sent to all '. 'project members.'); } } return $note; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/view/PhabricatorProjectCardView.php
src/applications/project/view/PhabricatorProjectCardView.php
<?php final class PhabricatorProjectCardView extends AphrontTagView { private $project; private $viewer; private $tag; public function setProject(PhabricatorProject $project) { $this->project = $project; return $this; } public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } public function setTag($tag) { $this->tag = $tag; return $this; } protected function getTagName() { if ($this->tag) { return $this->tag; } return 'div'; } protected function getTagAttributes() { $classes = array(); $classes[] = 'project-card-view'; $color = $this->project->getColor(); $classes[] = 'project-card-'.$color; return array( 'class' => implode(' ', $classes), ); } protected function getTagContent() { $project = $this->project; $viewer = $this->viewer; require_celerity_resource('project-card-view-css'); $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) ->setImage($project->getProfileImageURI()); if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) { $header->setStatus('fa-check', 'bluegrey', pht('Active')); } else { $header->setStatus('fa-ban', 'red', pht('Archived')); } $description = null; $card = phutil_tag( 'div', array( 'class' => 'project-card-inner', ), array( $header, $description, )); return $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/view/PhabricatorProjectWatcherListView.php
src/applications/project/view/PhabricatorProjectWatcherListView.php
<?php final class PhabricatorProjectWatcherListView extends PhabricatorProjectUserListView { protected function canEditList() { $viewer = $this->getViewer(); $project = $this->getProject(); return PhabricatorPolicyFilter::hasCapability( $viewer, $project, PhabricatorPolicyCapability::CAN_EDIT); } protected function getNoDataString() { return pht('This project does not have any watchers.'); } protected function getRemoveURI($phid) { $project = $this->getProject(); $id = $project->getID(); return "/project/watchers/{$id}/remove/?phid={$phid}"; } protected function getHeaderText() { return pht('Watchers'); } protected function getMembershipNote() { $viewer = $this->getViewer(); $viewer_phid = $viewer->getPHID(); $project = $this->getProject(); $note = null; if ($project->isUserWatcher($viewer_phid)) { $note = pht('You are watching this project and will receive mail about '. 'changes made to any related object.'); } return $note; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/view/ProjectBoardTaskCard.php
src/applications/project/view/ProjectBoardTaskCard.php
<?php final class ProjectBoardTaskCard extends Phobject { private $viewer; private $projectHandles; private $task; private $owner; private $showEditControls; private $canEdit; private $coverImageFile; private $hideArchivedProjects; public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } public function getViewer() { return $this->viewer; } public function setProjectHandles(array $handles) { $this->projectHandles = $handles; return $this; } public function getProjectHandles() { return $this->projectHandles; } public function setCoverImageFile(PhabricatorFile $cover_image_file) { $this->coverImageFile = $cover_image_file; return $this; } public function getCoverImageFile() { return $this->coverImageFile; } public function setHideArchivedProjects($hide_archived_projects) { $this->hideArchivedProjects = $hide_archived_projects; return $this; } public function getHideArchivedProjects() { return $this->hideArchivedProjects; } public function setTask(ManiphestTask $task) { $this->task = $task; return $this; } public function getTask() { return $this->task; } public function setOwner(PhabricatorObjectHandle $owner = null) { $this->owner = $owner; return $this; } public function getOwner() { return $this->owner; } public function setCanEdit($can_edit) { $this->canEdit = $can_edit; return $this; } public function getCanEdit() { return $this->canEdit; } public function setShowEditControls($show_edit_controls) { $this->showEditControls = $show_edit_controls; return $this; } public function getShowEditControls() { return $this->showEditControls; } public function getItem() { $task = $this->getTask(); $owner = $this->getOwner(); $can_edit = $this->getCanEdit(); $viewer = $this->getViewer(); $color_map = ManiphestTaskPriority::getColorMap(); $bar_color = idx($color_map, $task->getPriority(), 'grey'); $card = id(new PHUIObjectItemView()) ->setObject($task) ->setUser($viewer) ->setObjectName($task->getMonogram()) ->setHeader($task->getTitle()) ->setHref($task->getURI()) ->addSigil('project-card') ->setDisabled($task->isClosed()) ->setBarColor($bar_color); if ($this->getShowEditControls()) { if ($can_edit) { $card ->addSigil('draggable-card') ->addClass('draggable-card'); $edit_icon = 'fa-pencil'; } else { $card ->addClass('not-editable') ->addClass('undraggable-card'); $edit_icon = 'fa-lock red'; } $card->addAction( id(new PHUIListItemView()) ->setName(pht('Edit')) ->setIcon($edit_icon) ->addSigil('edit-project-card') ->setHref('/maniphest/task/edit/'.$task->getID().'/')); } if ($owner) { $card->addHandleIcon($owner, $owner->getName()); } $cover_file = $this->getCoverImageFile(); if ($cover_file) { $card->setCoverImage($cover_file->getBestURI()); } if (ManiphestTaskPoints::getIsEnabled()) { $points = $task->getPoints(); if ($points !== null) { $points_tag = id(new PHUITagView()) ->setType(PHUITagView::TYPE_SHADE) ->setColor(PHUITagView::COLOR_GREY) ->setSlimShady(true) ->setName($points) ->addClass('phui-workcard-points'); $card->addAttribute($points_tag); } } $subtype = $task->newSubtypeObject(); if ($subtype && $subtype->hasTagView()) { $subtype_tag = $subtype->newTagView() ->setSlimShady(true); $card->addAttribute($subtype_tag); } if ($task->isClosed()) { $icon = ManiphestTaskStatus::getStatusIcon($task->getStatus()); $icon = id(new PHUIIconView()) ->setIcon($icon.' grey'); $card->addAttribute($icon); $card->setBarColor('grey'); } $project_handles = $this->getProjectHandles(); // Remove any archived projects from the list. if ($this->hideArchivedProjects) { if ($project_handles) { foreach ($project_handles as $key => $handle) { if ($handle->getStatus() == PhabricatorObjectHandle::STATUS_CLOSED) { unset($project_handles[$key]); } } } } if ($project_handles) { $project_handles = array_reverse($project_handles); $tag_list = id(new PHUIHandleTagListView()) ->setSlim(true) ->setHandles($project_handles); $card->addAttribute($tag_list); } $card->addClass('phui-workcard'); return $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/view/PhabricatorProjectListView.php
src/applications/project/view/PhabricatorProjectListView.php
<?php final class PhabricatorProjectListView extends AphrontView { private $projects; private $showMember; private $showWatching; private $noDataString; public function setProjects(array $projects) { $this->projects = $projects; return $this; } public function getProjects() { return $this->projects; } public function setShowWatching($watching) { $this->showWatching = $watching; return $this; } public function setShowMember($member) { $this->showMember = $member; return $this; } public function setNoDataString($text) { $this->noDataString = $text; return $this; } public function renderList() { $viewer = $this->getUser(); $viewer_phid = $viewer->getPHID(); $projects = $this->getProjects(); $handles = $viewer->loadHandles(mpull($projects, 'getPHID')); $no_data = pht('No projects found.'); if ($this->noDataString) { $no_data = $this->noDataString; } $list = id(new PHUIObjectItemListView()) ->setUser($viewer) ->setNoDataString($no_data); foreach ($projects as $key => $project) { $id = $project->getID(); $icon = $project->getDisplayIconIcon(); $icon_icon = id(new PHUIIconView()) ->setIcon($icon); $icon_name = $project->getDisplayIconName(); $item = id(new PHUIObjectItemView()) ->setObject($project) ->setHeader($project->getName()) ->setHref("/project/view/{$id}/") ->setImageURI($project->getProfileImageURI()) ->addAttribute( array( $icon_icon, ' ', $icon_name, )); if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) { $item->addIcon('fa-ban', pht('Archived')); $item->setDisabled(true); } if ($this->showMember) { $is_member = $project->isUserMember($viewer_phid); if ($is_member) { $item->addIcon('fa-user', pht('Member')); } } if ($this->showWatching) { $is_watcher = $project->isUserWatcher($viewer_phid); if ($is_watcher) { $item->addIcon('fa-eye', pht('Watching')); } } $subtype = $project->newSubtypeObject(); if ($subtype && $subtype->hasTagView()) { $subtype_tag = $subtype->newTagView() ->setSlimShady(true); $item->addAttribute($subtype_tag); } $list->addItem($item); } return $list; } public function render() { return $this->renderList(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/view/PhabricatorProjectUserListView.php
src/applications/project/view/PhabricatorProjectUserListView.php
<?php abstract class PhabricatorProjectUserListView extends AphrontView { private $project; private $userPHIDs; private $limit; private $background; private $showNote; public function setProject(PhabricatorProject $project) { $this->project = $project; return $this; } public function getProject() { return $this->project; } public function setUserPHIDs(array $user_phids) { $this->userPHIDs = $user_phids; return $this; } public function getUserPHIDs() { return $this->userPHIDs; } public function setLimit($limit) { $this->limit = $limit; return $this; } public function getLimit() { return $this->limit; } public function setBackground($color) { $this->background = $color; return $this; } public function setShowNote($show) { $this->showNote = $show; return $this; } abstract protected function canEditList(); abstract protected function getNoDataString(); abstract protected function getRemoveURI($phid); abstract protected function getHeaderText(); abstract protected function getMembershipNote(); public function render() { $viewer = $this->getViewer(); $project = $this->getProject(); $user_phids = $this->getUserPHIDs(); $can_edit = $this->canEditList(); $supports_edit = $project->supportsEditMembers(); $no_data = $this->getNoDataString(); $list = id(new PHUIObjectItemListView()) ->setNoDataString($no_data); $limit = $this->getLimit(); $is_panel = (bool)$limit; $handles = $viewer->loadHandles($user_phids); // Reorder users in display order. We're going to put the viewer first // if they're a member, then enabled users, then disabled/invalid users. $phid_map = array(); foreach ($user_phids as $user_phid) { $handle = $handles[$user_phid]; $is_viewer = ($user_phid === $viewer->getPHID()); $is_enabled = ($handle->isComplete() && !$handle->isDisabled()); // If we're showing the main member list, show oldest to newest. If we're // showing only a slice in a panel, show newest to oldest. if ($limit) { $order_scalar = 1; } else { $order_scalar = -1; } $phid_map[$user_phid] = id(new PhutilSortVector()) ->addInt($is_viewer ? 0 : 1) ->addInt($is_enabled ? 0 : 1) ->addInt($order_scalar * count($phid_map)); } $phid_map = msortv($phid_map, 'getSelf'); $handles = iterator_to_array($handles); $handles = array_select_keys($handles, array_keys($phid_map)); if ($limit) { $handles = array_slice($handles, 0, $limit); } foreach ($handles as $user_phid => $handle) { $item = id(new PHUIObjectItemView()) ->setHeader($handle->getFullName()) ->setHref($handle->getURI()) ->setImageURI($handle->getImageURI()); if ($handle->isDisabled()) { if ($is_panel) { // Don't show disabled users in the panel view at all. continue; } $item ->setDisabled(true) ->addAttribute(pht('Disabled')); } else { $icon = id(new PHUIIconView()) ->setIcon($handle->getIcon()); $subtitle = $handle->getSubtitle(); $item->addAttribute(array($icon, ' ', $subtitle)); } if ($supports_edit && !$is_panel) { $remove_uri = $this->getRemoveURI($user_phid); $item->addAction( id(new PHUIListItemView()) ->setIcon('fa-times') ->setName(pht('Remove')) ->setHref($remove_uri) ->setDisabled(!$can_edit) ->setWorkflow(true)); } $list->addItem($item); } if ($user_phids) { $header_text = pht( '%s (%s)', $this->getHeaderText(), phutil_count($user_phids)); } else { $header_text = $this->getHeaderText(); } $id = $project->getID(); $header = id(new PHUIHeaderView()) ->setHeader($header_text); if ($limit) { $list->newTailButton() ->setText(pht('View All')) ->setHref("/project/members/{$id}/"); } $box = id(new PHUIObjectBoxView()) ->setHeader($header) ->setObjectList($list); if ($this->showNote) { if ($this->getMembershipNote()) { $info = id(new PHUIInfoView()) ->setSeverity(PHUIInfoView::SEVERITY_PLAIN) ->appendChild($this->getMembershipNote()); $box->setInfoView($info); } } if ($this->background) { $box->setBackground($this->background); } 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/order/PhabricatorProjectColumnNaturalOrder.php
src/applications/project/order/PhabricatorProjectColumnNaturalOrder.php
<?php final class PhabricatorProjectColumnNaturalOrder extends PhabricatorProjectColumnOrder { const ORDERKEY = 'natural'; public function getDisplayName() { return pht('Natural'); } public function getHasHeaders() { return false; } public function getCanReorder() { return true; } public function getMenuOrder() { return 0; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/order/PhabricatorProjectColumnHeader.php
src/applications/project/order/PhabricatorProjectColumnHeader.php
<?php final class PhabricatorProjectColumnHeader extends Phobject { private $orderKey; private $headerKey; private $sortVector; private $name; private $icon; private $editProperties; private $dropEffects = array(); public function setOrderKey($order_key) { $this->orderKey = $order_key; return $this; } public function getOrderKey() { return $this->orderKey; } public function setHeaderKey($header_key) { $this->headerKey = $header_key; return $this; } public function getHeaderKey() { return $this->headerKey; } public function setSortVector(array $sort_vector) { $this->sortVector = $sort_vector; return $this; } public function getSortVector() { return $this->sortVector; } public function setName($name) { $this->name = $name; return $this; } public function getName() { return $this->name; } public function setIcon(PHUIIconView$icon) { $this->icon = $icon; return $this; } public function getIcon() { return $this->icon; } public function setEditProperties(array $edit_properties) { $this->editProperties = $edit_properties; return $this; } public function getEditProperties() { return $this->editProperties; } public function addDropEffect(PhabricatorProjectDropEffect $effect) { $this->dropEffects[] = $effect; return $this; } public function getDropEffects() { return $this->dropEffects; } public function toDictionary() { return array( 'order' => $this->getOrderKey(), 'key' => $this->getHeaderKey(), 'template' => hsprintf('%s', $this->newView()), 'vector' => $this->getSortVector(), 'editProperties' => $this->getEditProperties(), 'effects' => mpull($this->getDropEffects(), 'toDictionary'), ); } private function newView() { $icon_view = $this->getIcon(); $name = $this->getName(); $template = phutil_tag( 'li', array( 'class' => 'workboard-group-header', ), array( $icon_view, phutil_tag( 'span', array( 'class' => 'workboard-group-header-name', ), $name), )); return $template; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/order/PhabricatorProjectColumnOwnerOrder.php
src/applications/project/order/PhabricatorProjectColumnOwnerOrder.php
<?php final class PhabricatorProjectColumnOwnerOrder extends PhabricatorProjectColumnOrder { const ORDERKEY = 'owner'; public function getDisplayName() { return pht('Group by Owner'); } protected function newMenuIconIcon() { return 'fa-users'; } public function getHasHeaders() { return true; } public function getCanReorder() { return true; } public function getMenuOrder() { return 2000; } protected function newHeaderKeyForObject($object) { return $this->newHeaderKeyForOwnerPHID($object->getOwnerPHID()); } private function newHeaderKeyForOwnerPHID($owner_phid) { if ($owner_phid === null) { $owner_phid = '<null>'; } return sprintf('owner(%s)', $owner_phid); } protected function newSortVectorsForObjects(array $objects) { $owner_phids = mpull($objects, null, 'getOwnerPHID'); $owner_phids = array_keys($owner_phids); $owner_phids = array_filter($owner_phids); if ($owner_phids) { $owner_users = id(new PhabricatorPeopleQuery()) ->setViewer($this->getViewer()) ->withPHIDs($owner_phids) ->execute(); $owner_users = mpull($owner_users, null, 'getPHID'); } else { $owner_users = array(); } $vectors = array(); foreach ($objects as $vector_key => $object) { $owner_phid = $object->getOwnerPHID(); if (!$owner_phid) { $vector = $this->newSortVectorForUnowned(); } else { $owner = idx($owner_users, $owner_phid); if ($owner) { $vector = $this->newSortVectorForOwner($owner); } else { $vector = $this->newSortVectorForOwnerPHID($owner_phid); } } $vectors[$vector_key] = $vector; } return $vectors; } private function newSortVectorForUnowned() { // Always put unasssigned tasks at the top. return array( 0, ); } private function newSortVectorForOwner(PhabricatorUser $user) { // Put assigned tasks with a valid owner after "Unassigned", but above // assigned tasks with an invalid owner. Sort these tasks by the owner's // username. return array( 1, $user->getUsername(), ); } private function newSortVectorForOwnerPHID($owner_phid) { // If we have tasks with a nonempty owner but can't load the associated // "User" object, move them to the bottom. We can only sort these by the // PHID. return array( 2, $owner_phid, ); } protected function newHeadersForObjects(array $objects) { $owner_phids = mpull($objects, null, 'getOwnerPHID'); $owner_phids = array_keys($owner_phids); $owner_phids = array_filter($owner_phids); if ($owner_phids) { $owner_users = id(new PhabricatorPeopleQuery()) ->setViewer($this->getViewer()) ->withPHIDs($owner_phids) ->needProfileImage(true) ->execute(); $owner_users = mpull($owner_users, null, 'getPHID'); } else { $owner_users = array(); } array_unshift($owner_phids, null); $headers = array(); foreach ($owner_phids as $owner_phid) { $header_key = $this->newHeaderKeyForOwnerPHID($owner_phid); $owner_image = null; $effect_content = null; if ($owner_phid === null) { $owner = null; $sort_vector = $this->newSortVectorForUnowned(); $owner_name = pht('Not Assigned'); $effect_content = pht('Remove task assignee.'); } else { $owner = idx($owner_users, $owner_phid); if ($owner) { $sort_vector = $this->newSortVectorForOwner($owner); $owner_name = $owner->getUsername(); $owner_image = $owner->getProfileImageURI(); $effect_content = pht( 'Assign task to %s.', phutil_tag('strong', array(), $owner_name)); } else { $sort_vector = $this->newSortVectorForOwnerPHID($owner_phid); $owner_name = pht('Unknown User ("%s")', $owner_phid); } } $owner_icon = 'fa-user'; $owner_color = 'bluegrey'; $icon_view = id(new PHUIIconView()); if ($owner_image) { $icon_view->setImage($owner_image); } else { $icon_view->setIcon($owner_icon, $owner_color); } $header = $this->newHeader() ->setHeaderKey($header_key) ->setSortVector($sort_vector) ->setName($owner_name) ->setIcon($icon_view) ->setEditProperties( array( 'value' => $owner_phid, )); if ($effect_content !== null) { $header->addDropEffect( $this->newEffect() ->setIcon($owner_icon) ->setColor($owner_color) ->addCondition('owner', '!=', $owner_phid) ->setContent($effect_content)); } $headers[] = $header; } return $headers; } protected function newColumnTransactions($object, array $header) { $new_owner = idx($header, 'value'); if ($object->getOwnerPHID() === $new_owner) { return null; } $xactions = array(); $xactions[] = $this->newTransaction($object) ->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) ->setNewValue($new_owner); 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/order/PhabricatorProjectColumnPriorityOrder.php
src/applications/project/order/PhabricatorProjectColumnPriorityOrder.php
<?php final class PhabricatorProjectColumnPriorityOrder extends PhabricatorProjectColumnOrder { const ORDERKEY = 'priority'; public function getDisplayName() { return pht('Group by Priority'); } protected function newMenuIconIcon() { return 'fa-sort-numeric-asc'; } public function getHasHeaders() { return true; } public function getCanReorder() { return true; } public function getMenuOrder() { return 1000; } protected function newHeaderKeyForObject($object) { return $this->newHeaderKeyForPriority($object->getPriority()); } private function newHeaderKeyForPriority($priority) { return sprintf('priority(%d)', $priority); } protected function newSortVectorForObject($object) { return $this->newSortVectorForPriority($object->getPriority()); } private function newSortVectorForPriority($priority) { return array( -1 * (int)$priority, ); } protected function newHeadersForObjects(array $objects) { $priorities = ManiphestTaskPriority::getTaskPriorityMap(); // It's possible for tasks to have an invalid/unknown priority in the // database. We still want to generate a header for these tasks so we // don't break the workboard. $priorities = $priorities + mpull($objects, null, 'getPriority'); $priorities = array_keys($priorities); $headers = array(); foreach ($priorities as $priority) { $header_key = $this->newHeaderKeyForPriority($priority); $sort_vector = $this->newSortVectorForPriority($priority); $priority_name = ManiphestTaskPriority::getTaskPriorityName($priority); $priority_color = ManiphestTaskPriority::getTaskPriorityColor($priority); $priority_icon = ManiphestTaskPriority::getTaskPriorityIcon($priority); $icon_view = id(new PHUIIconView()) ->setIcon($priority_icon, $priority_color); $drop_effect = $this->newEffect() ->setIcon($priority_icon) ->setColor($priority_color) ->addCondition('priority', '!=', $priority) ->setContent( pht( 'Change priority to %s.', phutil_tag('strong', array(), $priority_name))); $header = $this->newHeader() ->setHeaderKey($header_key) ->setSortVector($sort_vector) ->setName($priority_name) ->setIcon($icon_view) ->setEditProperties( array( 'value' => (int)$priority, )) ->addDropEffect($drop_effect); $headers[] = $header; } return $headers; } protected function newColumnTransactions($object, array $header) { $new_priority = idx($header, 'value'); if ($object->getPriority() === $new_priority) { return null; } $keyword_map = ManiphestTaskPriority::getTaskPriorityKeywordsMap(); $keyword = head(idx($keyword_map, $new_priority)); $xactions = array(); $xactions[] = $this->newTransaction($object) ->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE) ->setNewValue($keyword); 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/order/PhabricatorProjectColumnStatusOrder.php
src/applications/project/order/PhabricatorProjectColumnStatusOrder.php
<?php final class PhabricatorProjectColumnStatusOrder extends PhabricatorProjectColumnOrder { const ORDERKEY = 'status'; public function getDisplayName() { return pht('Group by Status'); } protected function newMenuIconIcon() { return 'fa-check'; } public function getHasHeaders() { return true; } public function getCanReorder() { return true; } public function getMenuOrder() { return 4000; } protected function newHeaderKeyForObject($object) { return $this->newHeaderKeyForStatus($object->getStatus()); } private function newHeaderKeyForStatus($status) { return sprintf('status(%s)', $status); } protected function newSortVectorsForObjects(array $objects) { $status_sequence = $this->newStatusSequence(); $vectors = array(); foreach ($objects as $object_key => $object) { $vectors[$object_key] = array( (int)idx($status_sequence, $object->getStatus(), 0), ); } return $vectors; } private function newStatusSequence() { $statuses = ManiphestTaskStatus::getTaskStatusMap(); return array_combine( array_keys($statuses), range(1, count($statuses))); } protected function newHeadersForObjects(array $objects) { $headers = array(); $statuses = ManiphestTaskStatus::getTaskStatusMap(); $sequence = $this->newStatusSequence(); foreach ($statuses as $status_key => $status_name) { $header_key = $this->newHeaderKeyForStatus($status_key); $sort_vector = array( (int)idx($sequence, $status_key, 0), ); $status_icon = ManiphestTaskStatus::getStatusIcon($status_key); $status_color = ManiphestTaskStatus::getStatusColor($status_key); $icon_view = id(new PHUIIconView()) ->setIcon($status_icon, $status_color); $drop_effect = $this->newEffect() ->setIcon($status_icon) ->setColor($status_color) ->addCondition('status', '!=', $status_key) ->setContent( pht( 'Change status to %s.', phutil_tag('strong', array(), $status_name))); $header = $this->newHeader() ->setHeaderKey($header_key) ->setSortVector($sort_vector) ->setName($status_name) ->setIcon($icon_view) ->setEditProperties( array( 'value' => $status_key, )) ->addDropEffect($drop_effect); $headers[] = $header; } return $headers; } protected function newColumnTransactions($object, array $header) { $new_status = idx($header, 'value'); if ($object->getStatus() === $new_status) { return null; } $xactions = array(); $xactions[] = $this->newTransaction($object) ->setTransactionType(ManiphestTaskStatusTransaction::TRANSACTIONTYPE) ->setNewValue($new_status); 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/order/PhabricatorProjectColumnOrder.php
src/applications/project/order/PhabricatorProjectColumnOrder.php
<?php abstract class PhabricatorProjectColumnOrder extends Phobject { private $viewer; final public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } final public function getViewer() { return $this->viewer; } final public function getColumnOrderKey() { return $this->getPhobjectClassConstant('ORDERKEY'); } final public static function getAllOrders() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getColumnOrderKey') ->setSortMethod('getMenuOrder') ->execute(); } final public static function getEnabledOrders() { $map = self::getAllOrders(); foreach ($map as $key => $order) { if (!$order->isEnabled()) { unset($map[$key]); } } return $map; } final public static function getOrderByKey($key) { $map = self::getAllOrders(); if (!isset($map[$key])) { throw new Exception( pht( 'No column ordering exists with key "%s".', $key)); } return $map[$key]; } final public function getColumnTransactions($object, array $header) { $result = $this->newColumnTransactions($object, $header); if (!is_array($result) && !is_null($result)) { throw new Exception( pht( 'Expected "newColumnTransactions()" on "%s" to return "null" or a '. 'list of transactions, but got "%s".', get_class($this), phutil_describe_type($result))); } if ($result === null) { $result = array(); } assert_instances_of($result, 'PhabricatorApplicationTransaction'); return $result; } final public function getMenuIconIcon() { return $this->newMenuIconIcon(); } protected function newMenuIconIcon() { return 'fa-sort-amount-asc'; } abstract public function getDisplayName(); abstract public function getHasHeaders(); abstract public function getCanReorder(); public function getMenuOrder() { return 9000; } public function isEnabled() { return true; } protected function newColumnTransactions($object, array $header) { return array(); } final public function getHeadersForObjects(array $objects) { $headers = $this->newHeadersForObjects($objects); if (!is_array($headers)) { throw new Exception( pht( 'Expected "newHeadersForObjects()" on "%s" to return a list '. 'of headers, but got "%s".', get_class($this), phutil_describe_type($headers))); } assert_instances_of($headers, 'PhabricatorProjectColumnHeader'); // Add a "0" to the end of each header. This makes them sort above object // cards in the same group. foreach ($headers as $header) { $vector = $header->getSortVector(); $vector[] = 0; $header->setSortVector($vector); } return $headers; } protected function newHeadersForObjects(array $objects) { return array(); } final public function getSortVectorsForObjects(array $objects) { $vectors = $this->newSortVectorsForObjects($objects); if (!is_array($vectors)) { throw new Exception( pht( 'Expected "newSortVectorsForObjects()" on "%s" to return a '. 'map of vectors, but got "%s".', get_class($this), phutil_describe_type($vectors))); } assert_same_keys($objects, $vectors); return $vectors; } protected function newSortVectorsForObjects(array $objects) { $vectors = array(); foreach ($objects as $key => $object) { $vectors[$key] = $this->newSortVectorForObject($object); } return $vectors; } protected function newSortVectorForObject($object) { return array(); } final public function getHeaderKeysForObjects(array $objects) { $header_keys = $this->newHeaderKeysForObjects($objects); if (!is_array($header_keys)) { throw new Exception( pht( 'Expected "newHeaderKeysForObject()" on "%s" to return a '. 'map of header keys, but got "%s".', get_class($this), phutil_describe_type($header_keys))); } assert_same_keys($objects, $header_keys); return $header_keys; } protected function newHeaderKeysForObjects(array $objects) { $header_keys = array(); foreach ($objects as $key => $object) { $header_keys[$key] = $this->newHeaderKeyForObject($object); } return $header_keys; } protected function newHeaderKeyForObject($object) { return null; } final protected function newTransaction($object) { return $object->getApplicationTransactionTemplate(); } final protected function newHeader() { return id(new PhabricatorProjectColumnHeader()) ->setOrderKey($this->getColumnOrderKey()); } final protected function newEffect() { return new PhabricatorProjectDropEffect(); } final public function toDictionary() { return array( 'orderKey' => $this->getColumnOrderKey(), 'hasHeaders' => $this->getHasHeaders(), 'canReorder' => $this->getCanReorder(), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/order/PhabricatorProjectColumnAuthorOrder.php
src/applications/project/order/PhabricatorProjectColumnAuthorOrder.php
<?php final class PhabricatorProjectColumnAuthorOrder extends PhabricatorProjectColumnOrder { const ORDERKEY = 'author'; public function getDisplayName() { return pht('Group by Author'); } protected function newMenuIconIcon() { return 'fa-user-plus'; } public function getHasHeaders() { return true; } public function getCanReorder() { return false; } public function getMenuOrder() { return 3000; } protected function newHeaderKeyForObject($object) { return $this->newHeaderKeyForAuthorPHID($object->getAuthorPHID()); } private function newHeaderKeyForAuthorPHID($author_phid) { return sprintf('author(%s)', $author_phid); } protected function newSortVectorsForObjects(array $objects) { $author_phids = mpull($objects, null, 'getAuthorPHID'); $author_phids = array_keys($author_phids); $author_phids = array_filter($author_phids); if ($author_phids) { $author_users = id(new PhabricatorPeopleQuery()) ->setViewer($this->getViewer()) ->withPHIDs($author_phids) ->execute(); $author_users = mpull($author_users, null, 'getPHID'); } else { $author_users = array(); } $vectors = array(); foreach ($objects as $vector_key => $object) { $author_phid = $object->getAuthorPHID(); $author = idx($author_users, $author_phid); if ($author) { $vector = $this->newSortVectorForAuthor($author); } else { $vector = $this->newSortVectorForAuthorPHID($author_phid); } $vectors[$vector_key] = $vector; } return $vectors; } private function newSortVectorForAuthor(PhabricatorUser $user) { return array( 1, $user->getUsername(), ); } private function newSortVectorForAuthorPHID($author_phid) { return array( 2, $author_phid, ); } protected function newHeadersForObjects(array $objects) { $author_phids = mpull($objects, null, 'getAuthorPHID'); $author_phids = array_keys($author_phids); $author_phids = array_filter($author_phids); if ($author_phids) { $author_users = id(new PhabricatorPeopleQuery()) ->setViewer($this->getViewer()) ->withPHIDs($author_phids) ->needProfileImage(true) ->execute(); $author_users = mpull($author_users, null, 'getPHID'); } else { $author_users = array(); } $headers = array(); foreach ($author_phids as $author_phid) { $header_key = $this->newHeaderKeyForAuthorPHID($author_phid); $author = idx($author_users, $author_phid); if ($author) { $sort_vector = $this->newSortVectorForAuthor($author); $author_name = $author->getUsername(); $author_image = $author->getProfileImageURI(); } else { $sort_vector = $this->newSortVectorForAuthorPHID($author_phid); $author_name = pht('Unknown User ("%s")', $author_phid); $author_image = null; } $author_icon = 'fa-user'; $author_color = 'bluegrey'; $icon_view = id(new PHUIIconView()); if ($author_image) { $icon_view->setImage($author_image); } else { $icon_view->setIcon($author_icon, $author_color); } $header = $this->newHeader() ->setHeaderKey($header_key) ->setSortVector($sort_vector) ->setName($author_name) ->setIcon($icon_view) ->setEditProperties( array( 'value' => $author_phid, )); $headers[] = $header; } return $headers; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/order/PhabricatorProjectColumnCreatedOrder.php
src/applications/project/order/PhabricatorProjectColumnCreatedOrder.php
<?php final class PhabricatorProjectColumnCreatedOrder extends PhabricatorProjectColumnOrder { const ORDERKEY = 'created'; public function getDisplayName() { return pht('Sort by Created Date'); } protected function newMenuIconIcon() { return 'fa-clock-o'; } public function getHasHeaders() { return false; } public function getCanReorder() { return false; } public function getMenuOrder() { return 5000; } protected function newSortVectorForObject($object) { return array( -1 * (int)$object->getDateCreated(), -1 * (int)$object->getID(), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/order/PhabricatorProjectColumnTitleOrder.php
src/applications/project/order/PhabricatorProjectColumnTitleOrder.php
<?php final class PhabricatorProjectColumnTitleOrder extends PhabricatorProjectColumnOrder { const ORDERKEY = 'title'; public function getDisplayName() { return pht('Sort by Title'); } protected function newMenuIconIcon() { return 'fa-sort-alpha-asc'; } public function getHasHeaders() { return false; } public function getCanReorder() { return false; } public function getMenuOrder() { return 7000; } protected function newSortVectorForObject($object) { return array( $object->getTitle(), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/order/PhabricatorProjectColumnPointsOrder.php
src/applications/project/order/PhabricatorProjectColumnPointsOrder.php
<?php final class PhabricatorProjectColumnPointsOrder extends PhabricatorProjectColumnOrder { const ORDERKEY = 'points'; public function getDisplayName() { return pht('Sort by Points'); } protected function newMenuIconIcon() { return 'fa-map-pin'; } public function isEnabled() { return ManiphestTaskPoints::getIsEnabled(); } public function getHasHeaders() { return false; } public function getCanReorder() { return false; } public function getMenuOrder() { return 6000; } protected function newSortVectorForObject($object) { $points = $object->getPoints(); // Put cards with no points on top. $has_points = ($points !== null); if (!$has_points) { $overall_order = 0; } else { $overall_order = 1; } return array( $overall_order, -1.0 * (double)$points, -1 * (int)$object->getID(), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/edge/PhabricatorProjectMemberOfProjectEdgeType.php
src/applications/project/edge/PhabricatorProjectMemberOfProjectEdgeType.php
<?php final class PhabricatorProjectMemberOfProjectEdgeType extends PhabricatorEdgeType { const EDGECONST = 14; public function getInverseEdgeConstant() { return PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; } public function shouldWriteInverseTransactions() { return true; } public function getTransactionAddString( $actor, $add_count, $add_edges) { return pht( '%s added %s project(s): %s.', $actor, $add_count, $add_edges); } public function getTransactionRemoveString( $actor, $rem_count, $rem_edges) { return pht( '%s removed %s project(s): %s.', $actor, $rem_count, $rem_edges); } public function getTransactionEditString( $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited project(s), added %s: %s; removed %s: %s.', $actor, $add_count, $add_edges, $rem_count, $rem_edges); } public function getFeedAddString( $actor, $object, $add_count, $add_edges) { return pht( '%s added %s project(s) for %s: %s.', $actor, $add_count, $object, $add_edges); } public function getFeedRemoveString( $actor, $object, $rem_count, $rem_edges) { return pht( '%s removed %s project(s) for %s: %s.', $actor, $rem_count, $object, $rem_edges); } public function getFeedEditString( $actor, $object, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited project(s) for %s, added %s: %s; removed %s: %s.', $actor, $object, $add_count, $add_edges, $rem_count, $rem_edges); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php
src/applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php
<?php final class PhabricatorProjectObjectHasProjectEdgeType extends PhabricatorEdgeType { const EDGECONST = 41; public function getInverseEdgeConstant() { return PhabricatorProjectProjectHasObjectEdgeType::EDGECONST; } public function getTransactionPreviewString($actor) { return pht( '%s edited associated projects.', $actor); } public function getTransactionAddString( $actor, $add_count, $add_edges) { return pht( '%s added %s project(s): %s.', $actor, $add_count, $add_edges); } public function getTransactionRemoveString( $actor, $rem_count, $rem_edges) { return pht( '%s removed %s project(s): %s.', $actor, $rem_count, $rem_edges); } public function getTransactionEditString( $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited %s project(s), added %s: %s; removed %s: %s.', $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges); } public function getFeedAddString( $actor, $object, $add_count, $add_edges) { return pht( '%s added %s project(s) to %s: %s.', $actor, $add_count, $object, $add_edges); } public function getFeedRemoveString( $actor, $object, $rem_count, $rem_edges) { return pht( '%s removed %s project(s) from %s: %s.', $actor, $rem_count, $object, $rem_edges); } public function getFeedEditString( $actor, $object, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited %s project(s) for %s, added %s: %s; removed %s: %s.', $actor, $total_count, $object, $add_count, $add_edges, $rem_count, $rem_edges); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/edge/PhabricatorProjectSilencedEdgeType.php
src/applications/project/edge/PhabricatorProjectSilencedEdgeType.php
<?php final class PhabricatorProjectSilencedEdgeType extends PhabricatorEdgeType { const EDGECONST = 61; }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/edge/PhabricatorProjectProjectHasMemberEdgeType.php
src/applications/project/edge/PhabricatorProjectProjectHasMemberEdgeType.php
<?php final class PhabricatorProjectProjectHasMemberEdgeType extends PhabricatorEdgeType { const EDGECONST = 13; public function getInverseEdgeConstant() { return PhabricatorProjectMemberOfProjectEdgeType::EDGECONST; } public function shouldWriteInverseTransactions() { return true; } public function getTransactionAddString( $actor, $add_count, $add_edges) { return pht( '%s added %s member(s): %s.', $actor, $add_count, $add_edges); } public function getTransactionRemoveString( $actor, $rem_count, $rem_edges) { return pht( '%s removed %s member(s): %s.', $actor, $rem_count, $rem_edges); } public function getTransactionEditString( $actor, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited member(s), added %s: %s; removed %s: %s.', $actor, $add_count, $add_edges, $rem_count, $rem_edges); } public function getFeedAddString( $actor, $object, $add_count, $add_edges) { return pht( '%s added %s member(s) for %s: %s.', $actor, $add_count, $object, $add_edges); } public function getFeedRemoveString( $actor, $object, $rem_count, $rem_edges) { return pht( '%s removed %s member(s) for %s: %s.', $actor, $rem_count, $object, $rem_edges); } public function getFeedEditString( $actor, $object, $total_count, $add_count, $add_edges, $rem_count, $rem_edges) { return pht( '%s edited member(s) for %s, added %s: %s; removed %s: %s.', $actor, $object, $add_count, $add_edges, $rem_count, $rem_edges); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php
src/applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php
<?php final class PhabricatorProjectProjectHasObjectEdgeType extends PhabricatorEdgeType { const EDGECONST = 42; public function getInverseEdgeConstant() { return PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/edge/PhabricatorProjectMaterializedMemberEdgeType.php
src/applications/project/edge/PhabricatorProjectMaterializedMemberEdgeType.php
<?php final class PhabricatorProjectMaterializedMemberEdgeType extends PhabricatorEdgeType { const EDGECONST = 60; }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerPlaySoundRule.php
src/applications/project/trigger/PhabricatorProjectTriggerPlaySoundRule.php
<?php final class PhabricatorProjectTriggerPlaySoundRule extends PhabricatorProjectTriggerRule { const TRIGGERTYPE = 'sound'; public function getSelectControlName() { return pht('Play sound'); } protected function assertValidRuleRecordFormat($value) { if (!is_string($value)) { throw new Exception( pht( 'Status rule value should be a string, but is not (value is "%s").', phutil_describe_type($value))); } } protected function assertValidRuleRecordValue($value) { $map = self::getSoundMap(); if (!isset($map[$value])) { throw new Exception( pht( 'Sound ("%s") is not a valid sound.', $value)); } } protected function newDropTransactions($object, $value) { return array(); } protected function newDropEffects($value) { $sound_icon = 'fa-volume-up'; $sound_color = 'blue'; $sound_name = self::getSoundName($value); $content = pht( 'Play sound %s.', phutil_tag('strong', array(), $sound_name)); return array( $this->newEffect() ->setIcon($sound_icon) ->setColor($sound_color) ->setContent($content), ); } protected function getDefaultValue() { return head_key(self::getSoundMap()); } protected function getPHUIXControlType() { return 'select'; } protected function getPHUIXControlSpecification() { $map = self::getSoundMap(); $map = ipull($map, 'name'); return array( 'options' => $map, 'order' => array_keys($map), ); } public function getRuleViewLabel() { return pht('Play Sound'); } public function getRuleViewDescription($value) { $sound_name = self::getSoundName($value); return pht( 'Play sound %s.', phutil_tag('strong', array(), $sound_name)); } public function getRuleViewIcon($value) { $sound_icon = 'fa-volume-up'; $sound_color = 'blue'; return id(new PHUIIconView()) ->setIcon($sound_icon, $sound_color); } private static function getSoundName($value) { $map = self::getSoundMap(); $spec = idx($map, $value, array()); return idx($spec, 'name', $value); } private static function getSoundMap() { return array( 'bing' => array( 'name' => pht('Bing'), 'uri' => celerity_get_resource_uri('/rsrc/audio/basic/bing.mp3'), ), 'glass' => array( 'name' => pht('Glass'), 'uri' => celerity_get_resource_uri('/rsrc/audio/basic/ting.mp3'), ), ); } public function getSoundEffects() { $value = $this->getValue(); $map = self::getSoundMap(); $spec = idx($map, $value, array()); $uris = array(); if (isset($spec['uri'])) { $uris[] = $spec['uri']; } return $uris; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerRuleRecord.php
src/applications/project/trigger/PhabricatorProjectTriggerRuleRecord.php
<?php final class PhabricatorProjectTriggerRuleRecord extends Phobject { private $type; private $value; public function setType($type) { $this->type = $type; return $this; } public function getType() { return $this->type; } public function setValue($value) { $this->value = $value; return $this; } public function getValue() { return $this->value; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerManiphestStatusRule.php
src/applications/project/trigger/PhabricatorProjectTriggerManiphestStatusRule.php
<?php final class PhabricatorProjectTriggerManiphestStatusRule extends PhabricatorProjectTriggerRule { const TRIGGERTYPE = 'task.status'; public function getSelectControlName() { return pht('Change status to'); } protected function assertValidRuleRecordFormat($value) { if (!is_string($value)) { throw new Exception( pht( 'Status rule value should be a string, but is not (value is "%s").', phutil_describe_type($value))); } } protected function assertValidRuleRecordValue($value) { $map = ManiphestTaskStatus::getTaskStatusMap(); if (!isset($map[$value])) { throw new Exception( pht( 'Task status value ("%s") is not a valid task status. '. 'Valid statues are: %s.', $value, implode(', ', array_keys($map)))); } } protected function newDropTransactions($object, $value) { return array( $this->newTransaction() ->setTransactionType(ManiphestTaskStatusTransaction::TRANSACTIONTYPE) ->setNewValue($value), ); } protected function newDropEffects($value) { $status_name = ManiphestTaskStatus::getTaskStatusName($value); $status_icon = ManiphestTaskStatus::getStatusIcon($value); $status_color = ManiphestTaskStatus::getStatusColor($value); $content = pht( 'Change status to %s.', phutil_tag('strong', array(), $status_name)); return array( $this->newEffect() ->setIcon($status_icon) ->setColor($status_color) ->addCondition('status', '!=', $value) ->setContent($content), ); } protected function getDefaultValue() { return ManiphestTaskStatus::getDefaultClosedStatus(); } protected function getPHUIXControlType() { return 'select'; } protected function getPHUIXControlSpecification() { $map = ManiphestTaskStatus::getTaskStatusMap(); return array( 'options' => $map, 'order' => array_keys($map), ); } public function getRuleViewLabel() { return pht('Change Status'); } public function getRuleViewDescription($value) { $status_name = ManiphestTaskStatus::getTaskStatusName($value); return pht( 'Change task status to %s.', phutil_tag('strong', array(), $status_name)); } public function getRuleViewIcon($value) { $status_icon = ManiphestTaskStatus::getStatusIcon($value); $status_color = ManiphestTaskStatus::getStatusColor($value); return id(new PHUIIconView()) ->setIcon($status_icon, $status_color); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerRemoveProjectsRule.php
src/applications/project/trigger/PhabricatorProjectTriggerRemoveProjectsRule.php
<?php final class PhabricatorProjectTriggerRemoveProjectsRule extends PhabricatorProjectTriggerRule { const TRIGGERTYPE = 'task.projects.remove'; public function getSelectControlname() { return pht('Remove project tags'); } protected function getValueForEditorField() { return $this->getDatasource()->getWireTokens($this->getValue()); } protected function assertValidRuleRecordFormat($value) { if (!is_array($value)) { throw new Exception( pht( 'Remove project rule value should be a list, but is not '. '(value is "%s").', phutil_describe_type($value))); } } protected function assertValidRuleRecordValue($value) { if (!$value) { throw new Exception( pht( 'You must select at least one project tag to remove.')); } } protected function newDropTransactions($object, $value) { $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xaction = $object->getApplicationTransactionTemplate() ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $project_edge_type) ->setNewValue( array( '-' => array_fuse($value), )); return array($xaction); } protected function newDropEffects($value) { return array( $this->newEffect() ->setIcon('fa-briefcase', 'red') ->setContent($this->getRuleViewDescription($value)), ); } protected function getDefaultValue() { return null; } protected function getPHUIXControlType() { return 'tokenizer'; } private function getDatasource() { return id(new PhabricatorProjectDatasource()) ->setViewer($this->getViewer()); } protected function getPHUIXControlSpecification() { $template = id(new AphrontTokenizerTemplateView()) ->setViewer($this->getViewer()); $template_markup = $template->render(); $datasource = $this->getDatasource(); return array( 'markup' => (string)hsprintf('%s', $template_markup), 'config' => array( 'src' => $datasource->getDatasourceURI(), 'browseURI' => $datasource->getBrowseURI(), 'placeholder' => $datasource->getPlaceholderText(), 'limit' => $datasource->getLimit(), ), 'value' => null, ); } public function getRuleViewLabel() { return pht('Remove Project Tags'); } public function getRuleViewDescription($value) { return pht( 'Remove project tags: %s.', phutil_tag( 'strong', array(), $this->getViewer() ->renderHandleList($value) ->setAsInline(true) ->render())); } public function getRuleViewIcon($value) { return id(new PHUIIconView()) ->setIcon('fa-briefcase', 'red'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerManiphestOwnerRule.php
src/applications/project/trigger/PhabricatorProjectTriggerManiphestOwnerRule.php
<?php final class PhabricatorProjectTriggerManiphestOwnerRule extends PhabricatorProjectTriggerRule { const TRIGGERTYPE = 'task.owner'; public function getSelectControlName() { return pht('Assign task to'); } protected function getValueForEditorField() { return $this->getDatasource()->getWireTokens($this->getValue()); } private function convertTokenizerValueToOwner($value) { $value = head($value); if ($value === PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN) { $value = null; } return $value; } protected function assertValidRuleRecordFormat($value) { if (!is_array($value)) { throw new Exception( pht( 'Owner rule value should be a list, but is not (value is "%s").', phutil_describe_type($value))); } } protected function assertValidRuleRecordValue($value) { if (!$value) { throw new Exception( pht( 'Owner rule value is required. Specify a user to assign tasks '. 'to, or the token "none()" to unassign tasks.')); } if (count($value) > 1) { throw new Exception( pht( 'Owner rule value must have only one elmement (value is "%s").', implode(', ', $value))); } $owner_phid = $this->convertTokenizerValueToOwner($value); if ($owner_phid !== null) { $user = id(new PhabricatorPeopleQuery()) ->setViewer($this->getViewer()) ->withPHIDs(array($owner_phid)) ->executeOne(); if (!$user) { throw new Exception( pht( 'User PHID ("%s") is not a valid user.', $owner_phid)); } } } protected function newDropTransactions($object, $value) { $value = $this->convertTokenizerValueToOwner($value); return array( $this->newTransaction() ->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) ->setNewValue($value), ); } protected function newDropEffects($value) { $owner_value = $this->convertTokenizerValueToOwner($value); return array( $this->newEffect() ->setIcon('fa-user') ->setContent($this->getRuleViewDescription($value)) ->addCondition('owner', '!=', $owner_value), ); } protected function getDefaultValue() { return null; } protected function getPHUIXControlType() { return 'tokenizer'; } private function getDatasource() { $datasource = id(new ManiphestAssigneeDatasource()) ->setLimit(1); if ($this->getViewer()) { $datasource->setViewer($this->getViewer()); } return $datasource; } protected function getPHUIXControlSpecification() { $template = id(new AphrontTokenizerTemplateView()) ->setViewer($this->getViewer()); $template_markup = $template->render(); $datasource = $this->getDatasource(); return array( 'markup' => (string)hsprintf('%s', $template_markup), 'config' => array( 'src' => $datasource->getDatasourceURI(), 'browseURI' => $datasource->getBrowseURI(), 'placeholder' => $datasource->getPlaceholderText(), 'limit' => $datasource->getLimit(), ), 'value' => null, ); } public function getRuleViewLabel() { return pht('Change Owner'); } public function getRuleViewDescription($value) { $value = $this->convertTokenizerValueToOwner($value); if (!$value) { return pht('Unassign task.'); } else { return pht( 'Assign task to %s.', phutil_tag( 'strong', array(), $this->getViewer() ->renderHandle($value) ->render())); } } public function getRuleViewIcon($value) { return id(new PHUIIconView()) ->setIcon('fa-user', 'green'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerManiphestPriorityRule.php
src/applications/project/trigger/PhabricatorProjectTriggerManiphestPriorityRule.php
<?php final class PhabricatorProjectTriggerManiphestPriorityRule extends PhabricatorProjectTriggerRule { const TRIGGERTYPE = 'task.priority'; public function getSelectControlName() { return pht('Change priority to'); } protected function assertValidRuleRecordFormat($value) { if (!is_string($value)) { throw new Exception( pht( 'Priority rule value should be a string, but is not (value is "%s").', phutil_describe_type($value))); } } protected function assertValidRuleRecordValue($value) { $map = ManiphestTaskPriority::getTaskPriorityMap(); if (!isset($map[$value])) { throw new Exception( pht( 'Task priority value ("%s") is not a valid task priority. '. 'Valid priorities are: %s.', $value, implode(', ', array_keys($map)))); } } protected function newDropTransactions($object, $value) { $value = ManiphestTaskPriority::getKeywordForTaskPriority($value); return array( $this->newTransaction() ->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE) ->setNewValue($value), ); } protected function newDropEffects($value) { $priority_name = ManiphestTaskPriority::getTaskPriorityName($value); $priority_icon = ManiphestTaskPriority::getTaskPriorityIcon($value); $priority_color = ManiphestTaskPriority::getTaskPriorityColor($value); $content = pht( 'Change priority to %s.', phutil_tag('strong', array(), $priority_name)); return array( $this->newEffect() ->setIcon($priority_icon) ->setColor($priority_color) ->addCondition('priority', '!=', $value) ->setContent($content), ); } protected function getDefaultValue() { return ManiphestTaskPriority::getDefaultPriority(); } protected function getPHUIXControlType() { return 'select'; } protected function getPHUIXControlSpecification() { $map = ManiphestTaskPriority::getTaskPriorityMap(); return array( 'options' => $map, 'order' => array_keys($map), ); } public function getRuleViewLabel() { return pht('Change Priority'); } public function getRuleViewDescription($value) { $priority_name = ManiphestTaskPriority::getTaskPriorityName($value); return pht( 'Change task priority to %s.', phutil_tag('strong', array(), $priority_name)); } public function getRuleViewIcon($value) { $priority_icon = ManiphestTaskPriority::getTaskPriorityIcon($value); $priority_color = ManiphestTaskPriority::getTaskPriorityColor($value); return id(new PHUIIconView()) ->setIcon($priority_icon, $priority_color); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerInvalidRule.php
src/applications/project/trigger/PhabricatorProjectTriggerInvalidRule.php
<?php final class PhabricatorProjectTriggerInvalidRule extends PhabricatorProjectTriggerRule { const TRIGGERTYPE = 'invalid'; private $exception; public function setException(Exception $exception) { $this->exception = $exception; return $this; } public function getException() { return $this->exception; } public function getSelectControlName() { return pht('(Invalid Rule)'); } protected function isSelectableRule() { return false; } protected function assertValidRuleRecordFormat($value) { return; } protected function newDropTransactions($object, $value) { return array(); } protected function newDropEffects($value) { return array(); } protected function isValidRule() { return false; } protected function newInvalidView() { return array( id(new PHUIIconView()) ->setIcon('fa-exclamation-triangle red'), ' ', pht( 'This is a trigger rule with a valid type ("%s") but an invalid '. 'value.', $this->getRecord()->getType()), ); } protected function getDefaultValue() { return null; } protected function getPHUIXControlType() { return null; } protected function getPHUIXControlSpecification() { return null; } public function getRuleViewLabel() { return pht('Invalid Rule'); } public function getRuleViewDescription($value) { $record = $this->getRecord(); $type = $record->getType(); $exception = $this->getException(); if ($exception) { return pht( 'This rule (of type "%s") is invalid: %s', $type, $exception->getMessage()); } else { return pht( 'This rule (of type "%s") is invalid.', $type); } } public function getRuleViewIcon($value) { return id(new PHUIIconView()) ->setIcon('fa-exclamation-triangle', 'red'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerRule.php
src/applications/project/trigger/PhabricatorProjectTriggerRule.php
<?php abstract class PhabricatorProjectTriggerRule extends Phobject { private $record; private $viewer; private $column; private $trigger; private $object; final public function getTriggerType() { return $this->getPhobjectClassConstant('TRIGGERTYPE', 64); } final public static function getAllTriggerRules() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getTriggerType') ->execute(); } final public function setRecord(PhabricatorProjectTriggerRuleRecord $record) { $value = $record->getValue(); $this->assertValidRuleRecordFormat($value); $this->record = $record; return $this; } final public function getRecord() { return $this->record; } final protected function getValue() { return $this->getRecord()->getValue(); } protected function getValueForEditorField() { return $this->getValue(); } abstract public function getSelectControlName(); abstract public function getRuleViewLabel(); abstract public function getRuleViewDescription($value); abstract public function getRuleViewIcon($value); abstract protected function assertValidRuleRecordFormat($value); final public function getRuleRecordValueValidationException() { try { $this->assertValidRuleRecordValue($this->getRecord()->getValue()); } catch (Exception $ex) { return $ex; } return null; } protected function assertValidRuleRecordValue($value) { return; } abstract protected function newDropTransactions($object, $value); abstract protected function newDropEffects($value); abstract protected function getDefaultValue(); abstract protected function getPHUIXControlType(); abstract protected function getPHUIXControlSpecification(); protected function isSelectableRule() { return true; } protected function isValidRule() { return true; } protected function newInvalidView() { return null; } public function getSoundEffects() { return array(); } final public function getDropTransactions($object, $value) { return $this->newDropTransactions($object, $value); } final public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } final public function getViewer() { return $this->viewer; } final public function setColumn(PhabricatorProjectColumn $column) { $this->column = $column; return $this; } final public function getColumn() { return $this->column; } final public function setTrigger(PhabricatorProjectTrigger $trigger) { $this->trigger = $trigger; return $this; } final public function getTrigger() { return $this->trigger; } final public function setObject( PhabricatorApplicationTransactionInterface $object) { $this->object = $object; return $this; } final public function getObject() { return $this->object; } final protected function newTransaction() { return $this->getObject()->getApplicationTransactionTemplate(); } final public function getDropEffects() { return $this->newDropEffects($this->getValue()); } final protected function newEffect() { return id(new PhabricatorProjectDropEffect()) ->setIsTriggerEffect(true); } final public function toDictionary() { $record = $this->getRecord(); $is_valid = $this->isValidRule(); if (!$is_valid) { $invalid_view = hsprintf('%s', $this->newInvalidView()); } else { $invalid_view = null; } return array( 'type' => $record->getType(), 'value' => $this->getValueForEditorField(), 'isValidRule' => $is_valid, 'invalidView' => $invalid_view, ); } final public function newTemplate() { return array( 'type' => $this->getTriggerType(), 'name' => $this->getSelectControlName(), 'selectable' => $this->isSelectableRule(), 'defaultValue' => $this->getDefaultValue(), 'control' => array( 'type' => $this->getPHUIXControlType(), 'specification' => $this->getPHUIXControlSpecification(), ), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerUnknownRule.php
src/applications/project/trigger/PhabricatorProjectTriggerUnknownRule.php
<?php final class PhabricatorProjectTriggerUnknownRule extends PhabricatorProjectTriggerRule { const TRIGGERTYPE = 'unknown'; public function getSelectControlName() { return pht('(Unknown Rule)'); } protected function isSelectableRule() { return false; } protected function assertValidRuleRecordFormat($value) { return; } protected function newDropTransactions($object, $value) { return array(); } protected function newDropEffects($value) { return array(); } protected function isValidRule() { return false; } protected function newInvalidView() { return array( id(new PHUIIconView()) ->setIcon('fa-exclamation-triangle yellow'), ' ', pht( 'This is a trigger rule with a unknown type ("%s").', $this->getRecord()->getType()), ); } protected function getDefaultValue() { return null; } protected function getPHUIXControlType() { return null; } protected function getPHUIXControlSpecification() { return null; } public function getRuleViewLabel() { return pht('Unknown Rule'); } public function getRuleViewDescription($value) { return pht( 'This is an unknown rule of type "%s". An administrator may have '. 'edited or removed an extension which implements this rule type.', $this->getRecord()->getType()); } public function getRuleViewIcon($value) { return id(new PHUIIconView()) ->setIcon('fa-question-circle', 'yellow'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php
src/applications/project/trigger/PhabricatorProjectTriggerAddProjectsRule.php
<?php final class PhabricatorProjectTriggerAddProjectsRule extends PhabricatorProjectTriggerRule { const TRIGGERTYPE = 'task.projects.add'; public function getSelectControlName() { return pht('Add project tags'); } protected function getValueForEditorField() { return $this->getDatasource()->getWireTokens($this->getValue()); } protected function assertValidRuleRecordFormat($value) { if (!is_array($value)) { throw new Exception( pht( 'Add project rule value should be a list, but is not '. '(value is "%s").', phutil_describe_type($value))); } } protected function assertValidRuleRecordValue($value) { if (!$value) { throw new Exception( pht( 'You must select at least one project tag to add.')); } } protected function newDropTransactions($object, $value) { $project_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xaction = $object->getApplicationTransactionTemplate() ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $project_edge_type) ->setNewValue( array( '+' => array_fuse($value), )); return array($xaction); } protected function newDropEffects($value) { return array( $this->newEffect() ->setIcon('fa-briefcase') ->setContent($this->getRuleViewDescription($value)), ); } protected function getDefaultValue() { return null; } protected function getPHUIXControlType() { return 'tokenizer'; } private function getDatasource() { return id(new PhabricatorProjectDatasource()) ->setViewer($this->getViewer()); } protected function getPHUIXControlSpecification() { $template = id(new AphrontTokenizerTemplateView()) ->setViewer($this->getViewer()); $template_markup = $template->render(); $datasource = $this->getDatasource(); return array( 'markup' => (string)hsprintf('%s', $template_markup), 'config' => array( 'src' => $datasource->getDatasourceURI(), 'browseURI' => $datasource->getBrowseURI(), 'placeholder' => $datasource->getPlaceholderText(), 'limit' => $datasource->getLimit(), ), 'value' => null, ); } public function getRuleViewLabel() { return pht('Add Project Tags'); } public function getRuleViewDescription($value) { return pht( 'Add project tags: %s.', phutil_tag( 'strong', array(), $this->getViewer() ->renderHandleList($value) ->setAsInline(true) ->render())); } public function getRuleViewIcon($value) { return id(new PHUIIconView()) ->setIcon('fa-briefcase', 'green'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/phid/PhabricatorProjectColumnPHIDType.php
src/applications/project/phid/PhabricatorProjectColumnPHIDType.php
<?php final class PhabricatorProjectColumnPHIDType extends PhabricatorPHIDType { const TYPECONST = 'PCOL'; public function getTypeName() { return pht('Project Column'); } public function getTypeIcon() { return 'fa-columns bluegrey'; } public function newObject() { return new PhabricatorProjectColumn(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorProjectApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new PhabricatorProjectColumnQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $column = $objects[$phid]; $handle->setName($column->getDisplayName()); $handle->setURI($column->getWorkboardURI()); if ($column->isHidden()) { $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); } } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/phid/PhabricatorProjectTriggerPHIDType.php
src/applications/project/phid/PhabricatorProjectTriggerPHIDType.php
<?php final class PhabricatorProjectTriggerPHIDType extends PhabricatorPHIDType { const TYPECONST = 'WTRG'; public function getTypeName() { return pht('Trigger'); } public function getTypeIcon() { return 'fa-exclamation-triangle'; } public function newObject() { return new PhabricatorProjectTrigger(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorProjectApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new PhabricatorProjectTriggerQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $trigger = $objects[$phid]; $handle->setName($trigger->getDisplayName()); $handle->setURI($trigger->getURI()); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/phid/PhabricatorProjectProjectPHIDType.php
src/applications/project/phid/PhabricatorProjectProjectPHIDType.php
<?php final class PhabricatorProjectProjectPHIDType extends PhabricatorPHIDType { const TYPECONST = 'PROJ'; public function getTypeName() { return pht('Project'); } public function getTypeIcon() { return 'fa-briefcase bluegrey'; } public function newObject() { return new PhabricatorProject(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorProjectApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new PhabricatorProjectQuery()) ->withPHIDs($phids) ->needImages(true); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { foreach ($handles as $phid => $handle) { $project = $objects[$phid]; $name = $project->getDisplayName(); $id = $project->getID(); $slug = $project->getPrimarySlug(); $handle->setName($name); if (strlen($slug)) { $handle->setObjectName('#'.$slug); $handle->setMailStampName('#'.$slug); $handle->setURI("/tag/{$slug}/"); } else { // We set the name to the project's PHID to avoid a parse error when a // project has no hashtag (as is the case with milestones by default). // See T12659 for more details. $handle->setCommandLineObjectName($project->getPHID()); $handle->setURI("/project/view/{$id}/"); } $handle->setImageURI($project->getProfileImageURI()); $handle->setIcon($project->getDisplayIconIcon()); $handle->setTagColor($project->getDisplayColor()); if ($project->isArchived()) { $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); } } } public static function getProjectMonogramPatternFragment() { // NOTE: See some discussion in ProjectRemarkupRule. return '[^\s,#]+'; } public function canLoadNamedObject($name) { $fragment = self::getProjectMonogramPatternFragment(); return preg_match('/^#'.$fragment.'$/i', $name); } public function loadNamedObjects( PhabricatorObjectQuery $query, array $names) { // If the user types "#YoloSwag", we still want to match "#yoloswag", so // we normalize, query, and then map back to the original inputs. $map = array(); foreach ($names as $key => $slug) { $map[$this->normalizeSlug(substr($slug, 1))][] = $slug; } $projects = id(new PhabricatorProjectQuery()) ->setViewer($query->getViewer()) ->withSlugs(array_keys($map)) ->needSlugs(true) ->execute(); $result = array(); foreach ($projects as $project) { $slugs = $project->getSlugs(); $slug_strs = mpull($slugs, 'getSlug'); foreach ($slug_strs as $slug) { $slug_map = idx($map, $slug, array()); foreach ($slug_map as $original) { $result[$original] = $project; } } } return $result; } private function normalizeSlug($slug) { // NOTE: We're using phutil_utf8_strtolower() (and not PhabricatorSlug's // normalize() method) because this normalization should be only somewhat // liberal. We want "#YOLO" to match against "#yolo", but "#\\yo!!lo" // should not. normalize() strips out most punctuation and leads to // excessively aggressive matches. return phutil_utf8_strtolower($slug); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/PhabricatorProjectHeraldFieldGroup.php
src/applications/project/herald/PhabricatorProjectHeraldFieldGroup.php
<?php final class PhabricatorProjectHeraldFieldGroup extends HeraldFieldGroup { const FIELDGROUPKEY = 'projects.project'; public function getGroupLabel() { return pht('Project Fields'); } protected function getGroupOrder() { return 500; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/PhabricatorProjectTagsField.php
src/applications/project/herald/PhabricatorProjectTagsField.php
<?php abstract class PhabricatorProjectTagsField extends HeraldField { public function getFieldGroupKey() { return HeraldSupportFieldGroup::FIELDGROUPKEY; } public function supportsObject($object) { return ($object instanceof PhabricatorProjectInterface); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectDatasource(); } final protected function getProjectTagsTransaction() { return $this->getAppliedEdgeTransactionOfType( PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/PhabricatorProjectTagsAddedField.php
src/applications/project/herald/PhabricatorProjectTagsAddedField.php
<?php final class PhabricatorProjectTagsAddedField extends PhabricatorProjectTagsField { const FIELDCONST = 'projects.added'; public function getHeraldFieldName() { return pht('Project tags added'); } public function getHeraldFieldValue($object) { $xaction = $this->getProjectTagsTransaction(); if (!$xaction) { return array(); } $record = PhabricatorEdgeChangeRecord::newFromTransaction($xaction); return $record->getAddedPHIDs(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/PhabricatorProjectHeraldAdapter.php
src/applications/project/herald/PhabricatorProjectHeraldAdapter.php
<?php final class PhabricatorProjectHeraldAdapter extends HeraldAdapter { private $project; protected function newObject() { return new PhabricatorProject(); } public function getAdapterApplicationClass() { return 'PhabricatorProjectApplication'; } public function getAdapterContentDescription() { return pht('React to projects being created or updated.'); } protected function initializeNewAdapter() { $this->project = $this->newObject(); } public function supportsApplicationEmail() { return true; } public function supportsRuleType($rule_type) { switch ($rule_type) { case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: return true; case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: default: return false; } } public function setProject(PhabricatorProject $project) { $this->project = $project; return $this; } public function getProject() { return $this->project; } public function getObject() { return $this->project; } public function getAdapterContentName() { return pht('Projects'); } public function getHeraldName() { return pht('Project %s', $this->getProject()->getName()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/PhabricatorProjectTagsRemovedField.php
src/applications/project/herald/PhabricatorProjectTagsRemovedField.php
<?php final class PhabricatorProjectTagsRemovedField extends PhabricatorProjectTagsField { const FIELDCONST = 'projects.removed'; public function getHeraldFieldName() { return pht('Project tags removed'); } public function getHeraldFieldValue($object) { $xaction = $this->getProjectTagsTransaction(); if (!$xaction) { return array(); } $record = PhabricatorEdgeChangeRecord::newFromTransaction($xaction); return $record->getRemovedPHIDs(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/HeraldExactProjectsField.php
src/applications/project/herald/HeraldExactProjectsField.php
<?php final class HeraldExactProjectsField extends HeraldField { const FIELDCONST = 'projects.exact'; public function getHeraldFieldName() { return pht('Projects being edited'); } public function getFieldGroupKey() { return PhabricatorProjectHeraldFieldGroup::FIELDGROUPKEY; } public function supportsObject($object) { return ($object instanceof PhabricatorProject); } public function getHeraldFieldValue($object) { return array($object->getPHID()); } protected function getHeraldFieldStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectDatasource(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/PhabricatorProjectHeraldAction.php
src/applications/project/herald/PhabricatorProjectHeraldAction.php
<?php abstract class PhabricatorProjectHeraldAction extends HeraldAction { const DO_ADD_PROJECTS = 'do.add-projects'; const DO_REMOVE_PROJECTS = 'do.remove-projects'; public function getActionGroupKey() { return HeraldSupportActionGroup::ACTIONGROUPKEY; } public function supportsObject($object) { return ($object instanceof PhabricatorProjectInterface); } public function supportsRuleType($rule_type) { return ($rule_type == HeraldRuleTypeConfig::RULE_TYPE_GLOBAL); } protected function applyProjects(array $phids, $is_add) { $adapter = $this->getAdapter(); $allowed_types = array( PhabricatorProjectProjectPHIDType::TYPECONST, ); // Detection of "No Effect" is a bit tricky for this action, so just do it // manually a little later on. $current = array(); $targets = $this->loadStandardTargets($phids, $allowed_types, $current); if (!$targets) { return; } $phids = array_fuse(array_keys($targets)); $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $current = $adapter->loadEdgePHIDs($project_type); if ($is_add) { $already = array(); foreach ($phids as $phid) { if (isset($current[$phid])) { $already[$phid] = $phid; unset($phids[$phid]); } } if ($already) { $this->logEffect(self::DO_STANDARD_NO_EFFECT, $already); } } else { $already = array(); foreach ($phids as $phid) { if (empty($current[$phid])) { $already[$phid] = $phid; unset($phids[$phid]); } } if ($already) { $this->logEffect(self::DO_STANDARD_NO_EFFECT, $already); } } if (!$phids) { return; } if ($is_add) { $kind = '+'; } else { $kind = '-'; } $xaction = $adapter->newTransaction() ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $project_type) ->setNewValue( array( $kind => $phids, )); $adapter->queueTransaction($xaction); if ($is_add) { $this->logEffect(self::DO_ADD_PROJECTS, $phids); } else { $this->logEffect(self::DO_REMOVE_PROJECTS, $phids); } } protected function getActionEffectMap() { return array( self::DO_ADD_PROJECTS => array( 'icon' => 'fa-briefcase', 'color' => 'green', 'name' => pht('Added Projects'), ), self::DO_REMOVE_PROJECTS => array( 'icon' => 'fa-minus-circle', 'color' => 'green', 'name' => pht('Removed Projects'), ), ); } protected function renderActionEffectDescription($type, $data) { switch ($type) { case self::DO_ADD_PROJECTS: return pht( 'Added %s project(s): %s.', phutil_count($data), $this->renderHandleList($data)); case self::DO_REMOVE_PROJECTS: return pht( 'Removed %s project(s): %s.', phutil_count($data), $this->renderHandleList($data)); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/PhabricatorProjectAddHeraldAction.php
src/applications/project/herald/PhabricatorProjectAddHeraldAction.php
<?php final class PhabricatorProjectAddHeraldAction extends PhabricatorProjectHeraldAction { const ACTIONCONST = 'projects.add'; public function getHeraldActionName() { return pht('Add projects'); } public function applyEffect($object, HeraldEffect $effect) { return $this->applyProjects($effect->getTarget(), $is_add = true); } public function getHeraldActionStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectDatasource(); } public function renderActionDescription($value) { return pht('Add projects: %s.', $this->renderHandleList($value)); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/HeraldProjectsField.php
src/applications/project/herald/HeraldProjectsField.php
<?php final class HeraldProjectsField extends PhabricatorProjectTagsField { const FIELDCONST = 'projects'; public function getHeraldFieldName() { return pht('Project tags'); } public function getHeraldFieldValue($object) { return PhabricatorEdgeQuery::loadDestinationPHIDs( $object->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/herald/PhabricatorProjectRemoveHeraldAction.php
src/applications/project/herald/PhabricatorProjectRemoveHeraldAction.php
<?php final class PhabricatorProjectRemoveHeraldAction extends PhabricatorProjectHeraldAction { const ACTIONCONST = 'projects.remove'; public function getHeraldActionName() { return pht('Remove projects'); } public function applyEffect($object, HeraldEffect $effect) { return $this->applyProjects($effect->getTarget(), $is_add = false); } public function getHeraldActionStandardType() { return self::STANDARD_PHID_LIST; } protected function getDatasource() { return new PhabricatorProjectDatasource(); } public function renderActionDescription($value) { return pht('Remove projects: %s.', $this->renderHandleList($value)); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/config/PhabricatorProjectConfigOptions.php
src/applications/project/config/PhabricatorProjectConfigOptions.php
<?php final class PhabricatorProjectConfigOptions extends PhabricatorApplicationConfigOptions { public function getName() { return pht('Projects'); } public function getDescription() { return pht('Configure Projects.'); } public function getIcon() { return 'fa-briefcase'; } public function getGroup() { return 'apps'; } public function getOptions() { $default_icons = PhabricatorProjectIconSet::getDefaultConfiguration(); $icons_type = 'project.icons'; $icons_description = $this->deformat(pht(<<<EOTEXT Allows you to change and customize the available project icons. You can find a list of available icons in {nav UIExamples > Icons and Images}. Configure a list of icon specifications. Each icon specification should be a dictionary, which may contain these keys: - `key` //Required string.// Internal key identifying the icon. - `name` //Required string.// Human-readable icon name. - `icon` //Required string.// Specifies which actual icon image to use. - `image` //Optional string.// Selects a default image. Select an image from `resources/builtins/projects/`. - `default` //Optional bool.// Selects a default icon. Exactly one icon must be selected as the default. - `disabled` //Optional bool.// If true, this icon will no longer be available for selection when creating or editing projects. - `special` //Optional string.// Marks an icon as a special icon: - `milestone` This is the icon for milestones. Exactly one icon must be selected as the milestone icon. You can look at the default configuration below for an example of a valid configuration. EOTEXT )); $default_colors = PhabricatorProjectIconSet::getDefaultColorMap(); $colors_type = 'project.colors'; $colors_description = $this->deformat(pht(<<<EOTEXT Allows you to relabel project colors. The list of available colors can not be expanded, but the existing colors may be given labels. Configure a list of color specifications. Each color specification should be a dictionary, which may contain these keys: - `key` //Required string.// The internal key identifying the color. - `name` //Required string.// Human-readable label for the color. - `default` //Optional bool.// Selects the default color used when creating new projects. Exactly one color must be selected as the default. You can look at the default configuration below for an example of a valid configuration. EOTEXT )); $default_fields = array( 'std:project:internal:description' => true, ); foreach ($default_fields as $key => $enabled) { $default_fields[$key] = array( 'disabled' => !$enabled, ); } $custom_field_type = 'custom:PhabricatorCustomFieldConfigOptionType'; $subtype_type = 'projects.subtypes'; $subtype_default_key = PhabricatorEditEngineSubtype::SUBTYPE_DEFAULT; $subtype_example = array( array( 'key' => $subtype_default_key, 'name' => pht('Project'), ), array( 'key' => 'team', 'name' => pht('Team'), ), ); $subtype_example = id(new PhutilJSON())->encodeAsList($subtype_example); $subtype_default = array( array( 'key' => $subtype_default_key, 'name' => pht('Project'), ), ); $subtype_description = $this->deformat(pht(<<<EOTEXT Allows you to define project subtypes. For a more detailed description of subtype configuration, see @{config:maniphest.subtypes}. EOTEXT )); return array( $this->newOption('projects.custom-field-definitions', 'wild', array()) ->setSummary(pht('Custom Projects fields.')) ->setDescription( pht( 'Array of custom fields for Projects.')) ->addExample( '{"mycompany:motto": {"name": "Project Motto", '. '"type": "text"}}', pht('Valid Setting')), $this->newOption('projects.fields', $custom_field_type, $default_fields) ->setCustomData(id(new PhabricatorProject())->getCustomFieldBaseClass()) ->setDescription(pht('Select and reorder project fields.')), $this->newOption('projects.icons', $icons_type, $default_icons) ->setSummary(pht('Adjust project icons.')) ->setDescription($icons_description), $this->newOption('projects.colors', $colors_type, $default_colors) ->setSummary(pht('Adjust project colors.')) ->setDescription($colors_description), $this->newOption('projects.subtypes', $subtype_type, $subtype_default) ->setSummary(pht('Define project subtypes.')) ->setDescription($subtype_description) ->addExample($subtype_example, pht('Simple Subtypes')), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/config/PhabricatorProjectSubtypesConfigType.php
src/applications/project/config/PhabricatorProjectSubtypesConfigType.php
<?php final class PhabricatorProjectSubtypesConfigType extends PhabricatorJSONConfigType { const TYPEKEY = 'projects.subtypes'; public function validateStoredValue( PhabricatorConfigOption $option, $value) { PhabricatorEditEngineSubtype::validateConfiguration($value); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/config/PhabricatorProjectColorsConfigType.php
src/applications/project/config/PhabricatorProjectColorsConfigType.php
<?php final class PhabricatorProjectColorsConfigType extends PhabricatorJSONConfigType { const TYPEKEY = 'project.colors'; public function validateStoredValue( PhabricatorConfigOption $option, $value) { PhabricatorProjectIconSet::validateColorConfiguration($value); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/config/PhabricatorProjectIconsConfigType.php
src/applications/project/config/PhabricatorProjectIconsConfigType.php
<?php final class PhabricatorProjectIconsConfigType extends PhabricatorJSONConfigType { const TYPEKEY = 'project.icons'; public function validateStoredValue( PhabricatorConfigOption $option, $value) { PhabricatorProjectIconSet::validateConfiguration($value); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/conduit/ProjectColumnSearchConduitAPIMethod.php
src/applications/project/conduit/ProjectColumnSearchConduitAPIMethod.php
<?php final class ProjectColumnSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'project.column.search'; } public function newSearchEngine() { return new PhabricatorProjectColumnSearchEngine(); } public function getMethodSummary() { return pht('Read information about workboard columns.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/conduit/ProjectQueryConduitAPIMethod.php
src/applications/project/conduit/ProjectQueryConduitAPIMethod.php
<?php final class ProjectQueryConduitAPIMethod extends ProjectConduitAPIMethod { public function getAPIMethodName() { return 'project.query'; } public function getMethodDescription() { return pht('Execute searches for Projects.'); } public function getMethodStatus() { return self::METHOD_STATUS_FROZEN; } public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. 'should use "project.search" instead.'); } protected function defineParamTypes() { $statuses = array( PhabricatorProjectQuery::STATUS_ANY, PhabricatorProjectQuery::STATUS_OPEN, PhabricatorProjectQuery::STATUS_CLOSED, PhabricatorProjectQuery::STATUS_ACTIVE, PhabricatorProjectQuery::STATUS_ARCHIVED, ); $status_const = $this->formatStringConstants($statuses); return array( 'ids' => 'optional list<int>', 'names' => 'optional list<string>', 'phids' => 'optional list<phid>', 'slugs' => 'optional list<string>', 'icons' => 'optional list<string>', 'colors' => 'optional list<string>', 'status' => 'optional '.$status_const, 'members' => 'optional list<phid>', 'limit' => 'optional int', 'offset' => 'optional int', ); } protected function defineReturnType() { return 'list'; } protected function execute(ConduitAPIRequest $request) { $query = new PhabricatorProjectQuery(); $query->setViewer($request->getUser()); $query->needMembers(true); $query->needSlugs(true); $ids = $request->getValue('ids'); if ($ids) { $query->withIDs($ids); } $names = $request->getValue('names'); if ($names) { $query->withNames($names); } $status = $request->getValue('status'); if ($status) { $query->withStatus($status); } $phids = $request->getValue('phids'); if ($phids) { $query->withPHIDs($phids); } $slugs = $request->getValue('slugs'); if ($slugs) { $query->withSlugs($slugs); } $request->getValue('icons'); if ($request->getValue('icons')) { $icons = array(); $query->withIcons($icons); } $colors = $request->getValue('colors'); if ($colors) { $query->withColors($colors); } $members = $request->getValue('members'); if ($members) { $query->withMemberPHIDs($members); } $limit = $request->getValue('limit'); if ($limit) { $query->setLimit($limit); } $offset = $request->getValue('offset'); if ($offset) { $query->setOffset($offset); } $pager = $this->newPager($request); $results = $query->executeWithCursorPager($pager); $projects = $this->buildProjectInfoDictionaries($results); // TODO: This is pretty hideous. $slug_map = array(); if ($slugs) { foreach ($slugs as $slug) { $normal = PhabricatorSlug::normalizeProjectSlug($slug); foreach ($projects as $project) { if (in_array($normal, $project['slugs'])) { $slug_map[$slug] = $project['phid']; } } } } $result = array( 'data' => $projects, 'slugMap' => $slug_map, ); return $this->addPagerResults($result, $pager); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/conduit/ProjectConduitAPIMethod.php
src/applications/project/conduit/ProjectConduitAPIMethod.php
<?php abstract class ProjectConduitAPIMethod extends ConduitAPIMethod { final public function getApplication() { return PhabricatorApplication::getByClass('PhabricatorProjectApplication'); } protected function buildProjectInfoDictionary(PhabricatorProject $project) { $results = $this->buildProjectInfoDictionaries(array($project)); return idx($results, $project->getPHID()); } protected function buildProjectInfoDictionaries(array $projects) { assert_instances_of($projects, 'PhabricatorProject'); if (!$projects) { return array(); } $result = array(); foreach ($projects as $project) { $member_phids = $project->getMemberPHIDs(); $member_phids = array_values($member_phids); $project_slugs = $project->getSlugs(); $project_slugs = array_values(mpull($project_slugs, 'getSlug')); $project_icon = $project->getDisplayIconKey(); $result[$project->getPHID()] = array( 'id' => $project->getID(), 'phid' => $project->getPHID(), 'name' => $project->getName(), 'profileImagePHID' => $project->getProfileImagePHID(), 'icon' => $project_icon, 'color' => $project->getColor(), 'members' => $member_phids, 'slugs' => $project_slugs, 'dateCreated' => $project->getDateCreated(), 'dateModified' => $project->getDateModified(), ); } return $result; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/conduit/ProjectSearchConduitAPIMethod.php
src/applications/project/conduit/ProjectSearchConduitAPIMethod.php
<?php final class ProjectSearchConduitAPIMethod extends PhabricatorSearchEngineAPIMethod { public function getAPIMethodName() { return 'project.search'; } public function newSearchEngine() { return new PhabricatorProjectSearchEngine(); } public function getMethodSummary() { return pht('Read information about projects.'); } protected function getCustomQueryMaps($query) { return array( 'slugMap' => $query->getSlugMap(), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/conduit/ProjectEditConduitAPIMethod.php
src/applications/project/conduit/ProjectEditConduitAPIMethod.php
<?php final class ProjectEditConduitAPIMethod extends PhabricatorEditEngineAPIMethod { public function getAPIMethodName() { return 'project.edit'; } public function newEditEngine() { return new PhabricatorProjectEditEngine(); } public function getMethodSummary() { return pht( 'Apply transactions to create a new project or edit an existing one.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/conduit/ProjectCreateConduitAPIMethod.php
src/applications/project/conduit/ProjectCreateConduitAPIMethod.php
<?php final class ProjectCreateConduitAPIMethod extends ProjectConduitAPIMethod { public function getAPIMethodName() { return 'project.create'; } public function getMethodDescription() { return pht('Create a project.'); } public function getMethodStatus() { return self::METHOD_STATUS_FROZEN; } public function getMethodStatusDescription() { return pht( 'This method is frozen and will eventually be deprecated. New code '. 'should use "project.edit" instead.'); } protected function defineParamTypes() { return array( 'name' => 'required string', 'members' => 'optional list<phid>', 'icon' => 'optional string', 'color' => 'optional string', 'tags' => 'optional list<string>', ); } protected function defineReturnType() { return 'dict'; } protected function execute(ConduitAPIRequest $request) { $user = $request->getUser(); $this->requireApplicationCapability( ProjectCreateProjectsCapability::CAPABILITY, $user); $project = PhabricatorProject::initializeNewProject($user); $type_name = PhabricatorProjectNameTransaction::TRANSACTIONTYPE; $name = $request->getValue('name'); if ($name === null || !strlen(name)) { throw new Exception(pht('Field "name" must be non-empty.')); } $members = $request->getValue('members'); if ($members === null) { $members = array(); } $xactions = array(); $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType($type_name) ->setNewValue($name); if ($request->getValue('icon')) { $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectIconTransaction::TRANSACTIONTYPE) ->setNewValue($request->getValue('icon')); } if ($request->getValue('color')) { $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectColorTransaction::TRANSACTIONTYPE) ->setNewValue($request->getValue('color')); } if ($request->getValue('tags')) { $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType( PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE) ->setNewValue($request->getValue('tags')); } $xactions[] = id(new PhabricatorProjectTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue( 'edge:type', PhabricatorProjectProjectHasMemberEdgeType::EDGECONST) ->setNewValue( array( '+' => array_fuse($members), )); $editor = id(new PhabricatorProjectTransactionEditor()) ->setActor($user) ->setContinueOnNoEffect(true) ->setContentSource($request->newContentSource()); $editor->applyTransactions($project, $xactions); return $this->buildProjectInfoDictionary($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/search/PhabricatorProjectFulltextEngine.php
src/applications/project/search/PhabricatorProjectFulltextEngine.php
<?php final class PhabricatorProjectFulltextEngine extends PhabricatorFulltextEngine { protected function buildAbstractDocument( PhabricatorSearchAbstractDocument $document, $object) { $project = $object; $viewer = $this->getViewer(); // Reload the project to get slugs. $project = id(new PhabricatorProjectQuery()) ->withIDs(array($project->getID())) ->setViewer($viewer) ->needSlugs(true) ->executeOne(); $project->updateDatasourceTokens(); $slugs = array(); foreach ($project->getSlugs() as $slug) { $slugs[] = $slug->getSlug(); } $body = implode("\n", $slugs); $document ->setDocumentTitle($project->getDisplayName()) ->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $body); $document->addRelationship( $project->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $project->getPHID(), PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorTime::getNow()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/search/PhabricatorProjectFerretEngine.php
src/applications/project/search/PhabricatorProjectFerretEngine.php
<?php final class PhabricatorProjectFerretEngine extends PhabricatorFerretEngine { public function getApplicationName() { return 'project'; } public function getScopeName() { return 'project'; } public function newSearchEngine() { return new PhabricatorProjectSearchEngine(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/chart/PhabricatorProjectBurndownChartEngine.php
src/applications/project/chart/PhabricatorProjectBurndownChartEngine.php
<?php final class PhabricatorProjectBurndownChartEngine extends PhabricatorChartEngine { const CHARTENGINEKEY = 'project.burndown'; public function setProjects(array $projects) { assert_instances_of($projects, 'PhabricatorProject'); $project_phids = mpull($projects, 'getPHID'); return $this->setEngineParameter('projectPHIDs', $project_phids); } protected function newChart(PhabricatorFactChart $chart, array $map) { $viewer = $this->getViewer(); $map = $map + array( 'projectPHIDs' => array(), ); if ($map['projectPHIDs']) { $projects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withPHIDs($map['projectPHIDs']) ->execute(); $project_phids = mpull($projects, 'getPHID'); } else { $project_phids = array(); } $functions = array(); if ($project_phids) { $open_function = $this->newFunction( array( 'accumulate', array( 'sum', $this->newFactSum( 'tasks.open-count.create.project', $project_phids), $this->newFactSum( 'tasks.open-count.status.project', $project_phids), $this->newFactSum( 'tasks.open-count.assign.project', $project_phids), ), )); $closed_function = $this->newFunction( array( 'accumulate', $this->newFactSum('tasks.open-count.status.project', $project_phids), )); } else { $open_function = $this->newFunction( array( 'accumulate', array( 'sum', array('fact', 'tasks.open-count.create'), array('fact', 'tasks.open-count.status'), ), )); $closed_function = $this->newFunction( array( 'accumulate', array('fact', 'tasks.open-count.status'), )); } $open_function->getFunctionLabel() ->setKey('open') ->setName(pht('Open Tasks')) ->setColor('rgba(0, 0, 200, 1)') ->setFillColor('rgba(0, 0, 200, 0.15)'); $closed_function->getFunctionLabel() ->setKey('closed') ->setName(pht('Closed Tasks')) ->setColor('rgba(0, 200, 0, 1)') ->setFillColor('rgba(0, 200, 0, 0.15)'); $datasets = array(); $dataset = id(new PhabricatorChartStackedAreaDataset()) ->setFunctions( array( $open_function, $closed_function, )) ->setStacks( array( array('open'), array('closed'), )); $datasets[] = $dataset; $chart->attachDatasets($datasets); } private function newFactSum($fact_key, array $phids) { $result = array(); $result[] = 'sum'; foreach ($phids as $phid) { $result[] = array('fact', $fact_key, $phid); } return $result; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/project/chart/PhabricatorProjectActivityChartEngine.php
src/applications/project/chart/PhabricatorProjectActivityChartEngine.php
<?php final class PhabricatorProjectActivityChartEngine extends PhabricatorChartEngine { const CHARTENGINEKEY = 'project.activity'; public function setProjects(array $projects) { assert_instances_of($projects, 'PhabricatorProject'); $project_phids = mpull($projects, 'getPHID'); return $this->setEngineParameter('projectPHIDs', $project_phids); } protected function newChart(PhabricatorFactChart $chart, array $map) { $viewer = $this->getViewer(); $map = $map + array( 'projectPHIDs' => array(), ); if ($map['projectPHIDs']) { $projects = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->withPHIDs($map['projectPHIDs']) ->execute(); $project_phids = mpull($projects, 'getPHID'); } else { $project_phids = array(); } $project_phid = head($project_phids); $functions = array(); $stacks = array(); $function = $this->newFunction( array( 'accumulate', array( 'compose', array('fact', 'tasks.open-count.assign.project', $project_phid), array('min', 0), ), )); $function->getFunctionLabel() ->setKey('moved-in') ->setName(pht('Tasks Moved Into Project')) ->setColor('rgba(128, 128, 200, 1)') ->setFillColor('rgba(128, 128, 200, 0.15)'); $functions[] = $function; $function = $this->newFunction( array( 'accumulate', array( 'compose', array('fact', 'tasks.open-count.status.project', $project_phid), array('min', 0), ), )); $function->getFunctionLabel() ->setKey('reopened') ->setName(pht('Tasks Reopened')) ->setColor('rgba(128, 128, 200, 1)') ->setFillColor('rgba(128, 128, 200, 0.15)'); $functions[] = $function; $function = $this->newFunction( array( 'accumulate', array('fact', 'tasks.open-count.create.project', $project_phid), )); $function->getFunctionLabel() ->setKey('created') ->setName(pht('Tasks Created')) ->setColor('rgba(0, 0, 200, 1)') ->setFillColor('rgba(0, 0, 200, 0.15)'); $functions[] = $function; $function = $this->newFunction( array( 'accumulate', array( 'compose', array('fact', 'tasks.open-count.status.project', $project_phid), array('max', 0), ), )); $function->getFunctionLabel() ->setKey('closed') ->setName(pht('Tasks Closed')) ->setColor('rgba(0, 200, 0, 1)') ->setFillColor('rgba(0, 200, 0, 0.15)'); $functions[] = $function; $function = $this->newFunction( array( 'accumulate', array( 'compose', array('fact', 'tasks.open-count.assign.project', $project_phid), array('max', 0), ), )); $function->getFunctionLabel() ->setKey('moved-out') ->setName(pht('Tasks Moved Out of Project')) ->setColor('rgba(128, 200, 128, 1)') ->setFillColor('rgba(128, 200, 128, 0.15)'); $functions[] = $function; $stacks[] = array('created', 'reopened', 'moved-in'); $stacks[] = array('closed', 'moved-out'); $datasets = array(); $dataset = id(new PhabricatorChartStackedAreaDataset()) ->setFunctions($functions) ->setStacks($stacks); $datasets[] = $dataset; $chart->attachDatasets($datasets); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false