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/system/engine/PhabricatorCacheEngineExtension.php
src/applications/system/engine/PhabricatorCacheEngineExtension.php
<?php abstract class PhabricatorCacheEngineExtension extends Phobject { final public function getExtensionKey() { return $this->getPhobjectClassConstant('EXTENSIONKEY'); } abstract public function getExtensionName(); public function discoverLinkedObjects( PhabricatorCacheEngine $engine, array $objects) { return array(); } public function deleteCaches( PhabricatorCacheEngine $engine, array $objects) { return null; } final public static function getAllExtensions() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getExtensionKey') ->execute(); } final public function selectObjects(array $objects, $class_name) { $results = array(); foreach ($objects as $phid => $object) { if ($object instanceof $class_name) { $results[$phid] = $object; } } return $results; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/system/engine/PhabricatorDestructionEngineExtensionModule.php
src/applications/system/engine/PhabricatorDestructionEngineExtensionModule.php
<?php final class PhabricatorDestructionEngineExtensionModule extends PhabricatorConfigModule { public function getModuleKey() { return 'destructionengine'; } public function getModuleName() { return pht('Engine: Destruction'); } public function renderModuleStatus(AphrontRequest $request) { $viewer = $request->getViewer(); $extensions = PhabricatorDestructionEngineExtension::getAllExtensions(); $rows = array(); foreach ($extensions as $extension) { $rows[] = array( get_class($extension), $extension->getExtensionName(), ); } return id(new AphrontTableView($rows)) ->setHeaders( array( pht('Class'), pht('Name'), )) ->setColumnClasses( array( null, 'wide pri', )); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/system/engine/PhabricatorSystemActionEngine.php
src/applications/system/engine/PhabricatorSystemActionEngine.php
<?php final class PhabricatorSystemActionEngine extends Phobject { /** * Prepare to take an action, throwing an exception if the user has exceeded * the rate limit. * * The `$actors` are a list of strings. Normally this will be a list of * user PHIDs, but some systems use other identifiers (like email * addresses). Each actor's score threshold is tracked independently. If * any actor exceeds the rate limit for the action, this method throws. * * The `$action` defines the actual thing being rate limited, and sets the * limit. * * You can pass either a positive, zero, or negative `$score` to this method: * * - If the score is positive, the user is given that many points toward * the rate limit after the limit is checked. Over time, this will cause * them to hit the rate limit and be prevented from taking further * actions. * - If the score is zero, the rate limit is checked but no score changes * are made. This allows you to check for a rate limit before beginning * a workflow, so the user doesn't fill in a form only to get rate limited * at the end. * - If the score is negative, the user is credited points, allowing them * to take more actions than the limit normally permits. By awarding * points for failed actions and credits for successful actions, a * system can be sensitive to failure without overly restricting * legitimate uses. * * If any actor is exceeding their rate limit, this method throws a * @{class:PhabricatorSystemActionRateLimitException}. * * @param list<string> List of actors. * @param PhabricatorSystemAction Action being taken. * @param float Score or credit, see above. * @return void */ public static function willTakeAction( array $actors, PhabricatorSystemAction $action, $score) { // If the score for this action is negative, we're giving the user a credit, // so don't bother checking if they're blocked or not. if ($score >= 0) { $blocked = self::loadBlockedActors($actors, $action, $score); if ($blocked) { foreach ($blocked as $actor => $actor_score) { throw new PhabricatorSystemActionRateLimitException( $action, $actor_score); } } } if ($score != 0) { $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); self::recordAction($actors, $action, $score); unset($unguarded); } } public static function loadBlockedActors( array $actors, PhabricatorSystemAction $action, $score) { $scores = self::loadScores($actors, $action); $window = self::getWindow(); $blocked = array(); foreach ($scores as $actor => $actor_score) { // For the purposes of checking for a block, we just use the raw // persistent score and do not include the score for this action. This // allows callers to test for a block without adding any points and get // the same result they would if they were adding points: we only // trigger a rate limit when the persistent score exceeds the threshold. if ($action->shouldBlockActor($actor, $actor_score)) { // When reporting the results, we do include the points for this // action. This makes the error messages more clear, since they // more accurately report the number of actions the user has really // tried to take. $blocked[$actor] = $actor_score + ($score / $window); } } return $blocked; } public static function loadScores( array $actors, PhabricatorSystemAction $action) { if (!$actors) { return array(); } $actor_hashes = array(); foreach ($actors as $actor) { $digest = PhabricatorHash::digestForIndex($actor); $actor_hashes[$digest] = $actor; } $log = new PhabricatorSystemActionLog(); $window = self::getWindow(); $conn = $log->establishConnection('r'); $rows = queryfx_all( $conn, 'SELECT actorHash, SUM(score) totalScore FROM %T WHERE action = %s AND actorHash IN (%Ls) AND epoch >= %d GROUP BY actorHash', $log->getTableName(), $action->getActionConstant(), array_keys($actor_hashes), (PhabricatorTime::getNow() - $window)); $rows = ipull($rows, 'totalScore', 'actorHash'); $scores = array(); foreach ($actor_hashes as $digest => $actor) { $score = idx($rows, $digest, 0); $scores[$actor] = ($score / $window); } return $scores; } private static function recordAction( array $actors, PhabricatorSystemAction $action, $score) { $log = new PhabricatorSystemActionLog(); $conn_w = $log->establishConnection('w'); $sql = array(); foreach ($actors as $actor) { $sql[] = qsprintf( $conn_w, '(%s, %s, %s, %f, %d)', PhabricatorHash::digestForIndex($actor), $actor, $action->getActionConstant(), $score, time()); } foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) { queryfx( $conn_w, 'INSERT INTO %T (actorHash, actorIdentity, action, score, epoch) VALUES %LQ', $log->getTableName(), $chunk); } } private static function getWindow() { // Limit queries to the last hour of data so we don't need to look at as // many rows. We can use an arbitrarily larger window instead (we normalize // scores to actions per second) but all the actions we care about limiting // have a limit much higher than one action per hour. return phutil_units('1 hour in seconds'); } /** * Reset all action counts for actions taken by some set of actors in the * previous action window. * * @param list<string> Actors to reset counts for. * @return int Number of actions cleared. */ public static function resetActions(array $actors) { $log = new PhabricatorSystemActionLog(); $conn_w = $log->establishConnection('w'); $now = PhabricatorTime::getNow(); $hashes = array(); foreach ($actors as $actor) { $hashes[] = PhabricatorHash::digestForIndex($actor); } queryfx( $conn_w, 'DELETE FROM %T WHERE actorHash IN (%Ls) AND epoch BETWEEN %d AND %d', $log->getTableName(), $hashes, $now - self::getWindow(), $now); return $conn_w->getAffectedRows(); } public static function newActorFromRequest(AphrontRequest $request) { return $request->getRemoteAddress(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/system/engine/PhabricatorCacheEngine.php
src/applications/system/engine/PhabricatorCacheEngine.php
<?php final class PhabricatorCacheEngine extends Phobject { public function getViewer() { return PhabricatorUser::getOmnipotentUser(); } public function updateObject($object) { $objects = array( $object->getPHID() => $object, ); $new_objects = $objects; while (true) { $discovered_objects = array(); $load = array(); $extensions = PhabricatorCacheEngineExtension::getAllExtensions(); foreach ($extensions as $key => $extension) { $discoveries = $extension->discoverLinkedObjects($this, $new_objects); if (!is_array($discoveries)) { throw new Exception( pht( 'Cache engine extension "%s" did not return a list of linked '. 'objects.', get_class($extension))); } foreach ($discoveries as $discovery) { if ($discovery === null) { // This is allowed because it makes writing extensions a lot // easier if they don't have to check that related PHIDs are // actually set to something. continue; } $is_phid = is_string($discovery); if ($is_phid) { $phid = $discovery; } else { $phid = $discovery->getPHID(); if (!$phid) { throw new Exception( pht( 'Cache engine extension "%s" returned object (of class '. '"%s") with no PHID.', get_class($extension), get_class($discovery))); } } if (isset($objects[$phid])) { continue; } if ($is_phid) { $load[$phid] = $phid; } else { $objects[$phid] = $discovery; $discovered_objects[$phid] = $discovery; // If another extension only knew about the PHID of this object, // we don't need to load it any more. unset($load[$phid]); } } } if ($load) { $load_objects = id(new PhabricatorObjectQuery()) ->setViewer($this->getViewer()) ->withPHIDs($load) ->execute(); foreach ($load_objects as $phid => $loaded_object) { $objects[$phid] = $loaded_object; $discovered_objects[$phid] = $loaded_object; } } // If we didn't find anything new to update, we're all set. if (!$discovered_objects) { break; } $new_objects = $discovered_objects; } foreach ($extensions as $extension) { $extension->deleteCaches($this, $objects); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/system/engine/PhabricatorDefaultUnlockEngine.php
src/applications/system/engine/PhabricatorDefaultUnlockEngine.php
<?php final class PhabricatorDefaultUnlockEngine extends PhabricatorUnlockEngine {}
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/system/codex/PhabricatorDestructibleCodex.php
src/applications/system/codex/PhabricatorDestructibleCodex.php
<?php abstract class PhabricatorDestructibleCodex extends Phobject { private $viewer; private $object; public function getDestructionNotes() { return array(); } final public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } final public function getViewer() { return $this->viewer; } final public function setObject( PhabricatorDestructibleCodexInterface $object) { $this->object = $object; return $this; } final public function getObject() { return $this->object; } final public static function newFromObject( PhabricatorDestructibleCodexInterface $object, PhabricatorUser $viewer) { if (!($object instanceof PhabricatorDestructibleInterface)) { throw new Exception( pht( 'Object (of class "%s") implements interface "%s", but must also '. 'implement interface "%s".', get_class($object), 'PhabricatorDestructibleCodexInterface', 'PhabricatorDestructibleInterface')); } $codex = $object->newDestructibleCodex(); if (!($codex instanceof PhabricatorDestructibleCodex)) { throw new Exception( pht( 'Object (of class "%s") implements interface "%s", but defines '. 'method "%s" incorrectly: this method must return an object of '. 'class "%s".', get_class($object), 'PhabricatorDestructibleCodexInterface', 'newDestructibleCodex()', __CLASS__)); } $codex ->setObject($object) ->setViewer($viewer); return $codex; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceItemManageController.php
src/applications/nuance/controller/NuanceItemManageController.php
<?php final class NuanceItemManageController extends NuanceController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $item = id(new NuanceItemQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$item) { return new Aphront404Response(); } $title = pht('Item %d', $item->getID()); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb( pht('Items'), $this->getApplicationURI('item/')); $crumbs->addTextCrumb( $title, $item->getURI()); $crumbs->addTextCrumb(pht('Manage')); $crumbs->setBorder(true); $properties = $this->buildPropertyView($item); $curtain = $this->buildCurtain($item); $header = id(new PHUIHeaderView()) ->setHeader($title); $timeline = $this->buildTransactionTimeline( $item, new NuanceItemTransactionQuery()); $timeline->setShouldTerminate(true); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->addPropertySection(pht('Details'), $properties) ->setMainColumn($timeline); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); } private function buildPropertyView(NuanceItem $item) { $viewer = $this->getViewer(); $properties = id(new PHUIPropertyListView()) ->setUser($viewer); $properties->addProperty( pht('Date Created'), phabricator_datetime($item->getDateCreated(), $viewer)); $requestor_phid = $item->getRequestorPHID(); if ($requestor_phid) { $requestor_view = $viewer->renderHandle($requestor_phid); } else { $requestor_view = phutil_tag('em', array(), pht('None')); } $properties->addProperty(pht('Requestor'), $requestor_view); $properties->addProperty( pht('Source'), $viewer->renderHandle($item->getSourcePHID())); $queue_phid = $item->getQueuePHID(); if ($queue_phid) { $queue_view = $viewer->renderHandle($queue_phid); } else { $queue_view = phutil_tag('em', array(), pht('None')); } $properties->addProperty(pht('Queue'), $queue_view); $source = $item->getSource(); $definition = $source->getDefinition(); $definition->renderItemEditProperties( $viewer, $item, $properties); return $properties; } private function buildCurtain(NuanceItem $item) { $viewer = $this->getViewer(); $id = $item->getID(); $curtain = $this->newCurtainView($item); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('View Item')) ->setIcon('fa-eye') ->setHref($item->getURI())); return $curtain; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceItemViewController.php
src/applications/nuance/controller/NuanceItemViewController.php
<?php final class NuanceItemViewController extends NuanceController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); $item = id(new NuanceItemQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$item) { return new Aphront404Response(); } $title = pht('Item %d', $item->getID()); $name = $item->getDisplayName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb( pht('Items'), $this->getApplicationURI('item/')); $crumbs->addTextCrumb($title); $crumbs->setBorder(true); $curtain = $this->buildCurtain($item); $content = $this->buildContent($item); $timeline = $this->buildTransactionTimeline( $item, new NuanceItemTransactionQuery()); $main = array( $content, $timeline, ); $header = id(new PHUIHeaderView()) ->setHeader($name); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->setMainColumn($main); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); } private function buildCurtain(NuanceItem $item) { $viewer = $this->getViewer(); $id = $item->getID(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $item, PhabricatorPolicyCapability::CAN_EDIT); $curtain = $this->newCurtainView($item); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Manage Item')) ->setIcon('fa-cogs') ->setHref($this->getApplicationURI("item/manage/{$id}/"))); $impl = $item->getImplementation(); $impl->setViewer($viewer); foreach ($impl->getItemActions($item) as $action) { $curtain->addAction($action); } foreach ($impl->getItemCurtainPanels($item) as $panel) { $curtain->addPanel($panel); } return $curtain; } private function buildContent(NuanceItem $item) { $viewer = $this->getViewer(); $impl = $item->getImplementation(); $impl->setViewer($viewer); return $impl->buildItemView($item); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceController.php
src/applications/nuance/controller/NuanceController.php
<?php abstract class NuanceController extends PhabricatorController {}
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceQueueWorkController.php
src/applications/nuance/controller/NuanceQueueWorkController.php
<?php final class NuanceQueueWorkController extends NuanceQueueController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $queue = id(new NuanceQueueQuery()) ->setViewer($viewer) ->withIDs(array($request->getURIData('id'))) ->executeOne(); if (!$queue) { return new Aphront404Response(); } $title = $queue->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Queues'), $this->getApplicationURI('queue/')); $crumbs->addTextCrumb($queue->getName(), $queue->getURI()); $crumbs->addTextCrumb(pht('Work')); $crumbs->setBorder(true); // For now, just pick the first open item. $items = id(new NuanceItemQuery()) ->setViewer($viewer) ->withQueuePHIDs( array( $queue->getPHID(), )) ->withStatuses( array( NuanceItem::STATUS_OPEN, )) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->setLimit(5) ->execute(); if (!$items) { return $this->newDialog() ->setTitle(pht('Queue Empty')) ->appendParagraph( pht( 'This queue has no open items which you have permission to '. 'work on.')) ->addCancelButton($queue->getURI()); } $item = head($items); $curtain = $this->buildCurtain($queue, $item); $timeline = $this->buildTransactionTimeline( $item, new NuanceItemTransactionQuery()); $timeline->setShouldTerminate(true); $impl = $item->getImplementation() ->setViewer($viewer); $commands = $this->buildCommands($item); $work_content = $impl->buildItemWorkView($item); $view = id(new PHUITwoColumnView()) ->setCurtain($curtain) ->setMainColumn( array( $commands, $work_content, $timeline, )); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); } private function buildCurtain(NuanceQueue $queue, NuanceItem $item) { $viewer = $this->getViewer(); $id = $queue->getID(); $curtain = $this->newCurtainView(); $impl = $item->getImplementation(); $commands = $impl->buildWorkCommands($item); foreach ($commands as $command) { $command_key = $command->getCommandKey(); $item_id = $item->getID(); $action_uri = "queue/action/{$id}/{$command_key}/{$item_id}/"; $action_uri = $this->getApplicationURI($action_uri); $curtain->addAction( id(new PhabricatorActionView()) ->setName($command->getName()) ->setIcon($command->getIcon()) ->setHref($action_uri) ->setWorkflow(true)); } $curtain->addAction( id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_DIVIDER)); $curtain->addAction( id(new PhabricatorActionView()) ->setType(PhabricatorActionView::TYPE_LABEL) ->setName(pht('Queue Actions'))); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Manage Queue')) ->setIcon('fa-cog') ->setHref($this->getApplicationURI("queue/view/{$id}/"))); return $curtain; } private function buildCommands(NuanceItem $item) { $viewer = $this->getViewer(); $commands = id(new NuanceItemCommandQuery()) ->setViewer($viewer) ->withItemPHIDs(array($item->getPHID())) ->withStatuses( array( NuanceItemCommand::STATUS_ISSUED, NuanceItemCommand::STATUS_EXECUTING, NuanceItemCommand::STATUS_FAILED, )) ->execute(); $commands = msort($commands, 'getID'); if (!$commands) { return null; } $rows = array(); foreach ($commands as $command) { $icon = $command->getStatusIcon(); $color = $command->getStatusColor(); $rows[] = array( $command->getID(), id(new PHUIIconView()) ->setIcon($icon, $color), $viewer->renderHandle($command->getAuthorPHID()), $command->getCommand(), phabricator_datetime($command->getDateCreated(), $viewer), ); } $table = id(new AphrontTableView($rows)) ->setHeaders( array( pht('ID'), null, pht('Actor'), pht('Command'), pht('Date'), )) ->setColumnClasses( array( null, 'icon', null, 'pri', 'wide right', )); return id(new PHUIObjectBoxView()) ->setHeaderText(pht('Pending Commands')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setTable($table); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceSourceListController.php
src/applications/nuance/controller/NuanceSourceListController.php
<?php final class NuanceSourceListController extends NuanceSourceController { public function handleRequest(AphrontRequest $request) { return id(new NuanceSourceSearchEngine()) ->setController($this) ->buildResponse(); } protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); id(new NuanceSourceEditEngine()) ->setViewer($this->getViewer()) ->addActionToCrumbs($crumbs); return $crumbs; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceItemController.php
src/applications/nuance/controller/NuanceItemController.php
<?php abstract class NuanceItemController extends NuanceController { public function buildApplicationMenu() { return $this->newApplicationMenu() ->setSearchEngine(new NuanceItemSearchEngine()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceQueueEditController.php
src/applications/nuance/controller/NuanceQueueEditController.php
<?php final class NuanceQueueEditController extends NuanceQueueController { public function handleRequest(AphrontRequest $request) { return id(new NuanceQueueEditEngine()) ->setController($this) ->buildResponse(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceSourceViewController.php
src/applications/nuance/controller/NuanceSourceViewController.php
<?php final class NuanceSourceViewController extends NuanceSourceController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $source = id(new NuanceSourceQuery()) ->setViewer($viewer) ->withIDs(array($request->getURIData('id'))) ->executeOne(); if (!$source) { return new Aphront404Response(); } $source_id = $source->getID(); $header = $this->buildHeaderView($source); $curtain = $this->buildCurtain($source); $properties = $this->buildPropertyView($source); $title = $source->getName(); $routing_list = id(new PHUIPropertyListView()) ->addProperty( pht('Default Queue'), $viewer->renderHandle($source->getDefaultQueuePHID())); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Sources'), $this->getApplicationURI('source/')); $crumbs->addTextCrumb($title); $crumbs->setBorder(true); $timeline = $this->buildTransactionTimeline( $source, new NuanceSourceTransactionQuery()); $timeline->setShouldTerminate(true); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->addPropertySection(pht('Details'), $properties) ->addPropertySection(pht('Routing'), $routing_list) ->setMainColumn($timeline); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); } private function buildHeaderView(NuanceSource $source) { $viewer = $this->getViewer(); $header = id(new PHUIHeaderView()) ->setUser($viewer) ->setHeader($source->getName()) ->setPolicyObject($source); return $header; } private function buildCurtain(NuanceSource $source) { $viewer = $this->getViewer(); $id = $source->getID(); $actions = id(new PhabricatorActionListView()) ->setUser($viewer); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $source, PhabricatorPolicyCapability::CAN_EDIT); $curtain = $this->newCurtainView($source); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Edit Source')) ->setIcon('fa-pencil') ->setHref($this->getApplicationURI("source/edit/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); $request = $this->getRequest(); $definition = $source->getDefinition(); $definition ->setViewer($viewer) ->setSource($source); $source_actions = $definition->getSourceViewActions($request); foreach ($source_actions as $source_action) { $curtain->addAction($source_action); } return $curtain; } private function buildPropertyView( NuanceSource $source) { $viewer = $this->getViewer(); $properties = id(new PHUIPropertyListView()) ->setViewer($viewer); $definition = $source->getDefinition(); $properties->addProperty( pht('Source Type'), $definition->getName()); return $properties; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceItemActionController.php
src/applications/nuance/controller/NuanceItemActionController.php
<?php final class NuanceItemActionController extends NuanceController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $id = $request->getURIData('id'); if (!$request->validateCSRF()) { return new Aphront400Response(); } // NOTE: This controller can be reached from an individual item (usually // by a user) or while working through a queue (usually by staff). When // a command originates from a queue, the URI will have a queue ID. $item = id(new NuanceItemQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$item) { return new Aphront404Response(); } $cancel_uri = $item->getURI(); $queue_id = $request->getURIData('queueID'); $queue = null; if ($queue_id) { $queue = id(new NuanceQueueQuery()) ->setViewer($viewer) ->withIDs(array($queue_id)) ->executeOne(); if (!$queue) { return new Aphront404Response(); } $item_queue = $item->getQueue(); if (!$item_queue || ($item_queue->getPHID() != $queue->getPHID())) { return $this->newDialog() ->setTitle(pht('Wrong Queue')) ->appendParagraph( pht( 'You are trying to act on this item from the wrong queue: it '. 'is currently in a different queue.')) ->addCancelButton($cancel_uri); } } $action = $request->getURIData('action'); $impl = $item->getImplementation(); $impl->setViewer($viewer); $impl->setController($this); $executors = NuanceCommandImplementation::getAllCommands(); $executor = idx($executors, $action); if (!$executor) { return new Aphront404Response(); } $executor = id(clone $executor) ->setActor($viewer); if (!$executor->canApplyToItem($item)) { return $this->newDialog() ->setTitle(pht('Command Not Supported')) ->appendParagraph( pht( 'This item does not support the specified command ("%s").', $action)) ->addCancelButton($cancel_uri); } $command = NuanceItemCommand::initializeNewCommand() ->setItemPHID($item->getPHID()) ->setAuthorPHID($viewer->getPHID()) ->setCommand($action); if ($queue) { $command->setQueuePHID($queue->getPHID()); } $command->save(); // If this command can be applied immediately, try to apply it now. // In most cases, local commands (like closing an item) can be applied // immediately. // Commands that require making a call to a remote system (for example, // to reply to a tweet or close a remote object) are usually done in the // background so the user doesn't have to wait for the operation to // complete before they can continue work. $did_apply = false; $immediate = $executor->canApplyImmediately($item, $command); if ($immediate) { // TODO: Move this stuff to a new Engine, and have the controller and // worker both call into the Engine. $worker = new NuanceItemUpdateWorker(array()); $did_apply = $worker->executeCommands($item, array($command)); } // If this can't be applied immediately or we were unable to get a lock // fast enough, do the update in the background instead. if (!$did_apply) { $item->scheduleUpdate(); } if ($queue) { $done_uri = $queue->getWorkURI(); } else { $done_uri = $item->getURI(); } return id(new AphrontRedirectResponse()) ->setURI($done_uri); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceSourceController.php
src/applications/nuance/controller/NuanceSourceController.php
<?php abstract class NuanceSourceController extends NuanceController { public function buildApplicationMenu() { return $this->newApplicationMenu() ->setSearchEngine(new NuanceSourceSearchEngine()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceSourceActionController.php
src/applications/nuance/controller/NuanceSourceActionController.php
<?php final class NuanceSourceActionController extends NuanceController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $source = id(new NuanceSourceQuery()) ->setViewer($viewer) ->withIDs(array($request->getURIData('id'))) ->executeOne(); if (!$source) { return new Aphront404Response(); } $def = $source->getDefinition(); $def ->setViewer($viewer) ->setSource($source); $response = $def->handleActionRequest($request); if ($response instanceof AphrontResponse) { return $response; } $title = $source->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($response); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceQueueViewController.php
src/applications/nuance/controller/NuanceQueueViewController.php
<?php final class NuanceQueueViewController extends NuanceQueueController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); $queue = id(new NuanceQueueQuery()) ->setViewer($viewer) ->withIDs(array($request->getURIData('id'))) ->executeOne(); if (!$queue) { return new Aphront404Response(); } $title = $queue->getName(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Queues'), $this->getApplicationURI('queue/')); $crumbs->addTextCrumb($queue->getName()); $crumbs->setBorder(true); $header = $this->buildHeaderView($queue); $curtain = $this->buildCurtain($queue); $timeline = $this->buildTransactionTimeline( $queue, new NuanceQueueTransactionQuery()); $timeline->setShouldTerminate(true); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setCurtain($curtain) ->setMainColumn($timeline); return $this->newPage() ->setTitle($title) ->setCrumbs($crumbs) ->appendChild($view); } private function buildHeaderView(NuanceQueue $queue) { $viewer = $this->getViewer(); $header = id(new PHUIHeaderView()) ->setUser($viewer) ->setHeader($queue->getName()) ->setPolicyObject($queue); return $header; } private function buildCurtain(NuanceQueue $queue) { $viewer = $this->getViewer(); $id = $queue->getID(); $can_edit = PhabricatorPolicyFilter::hasCapability( $viewer, $queue, PhabricatorPolicyCapability::CAN_EDIT); $curtain = $this->newCurtainView($queue); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Edit Queue')) ->setIcon('fa-pencil') ->setHref($this->getApplicationURI("queue/edit/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); $curtain->addAction( id(new PhabricatorActionView()) ->setName(pht('Begin Work')) ->setIcon('fa-play-circle-o') ->setHref($this->getApplicationURI("queue/work/{$id}/")) ->setDisabled(!$can_edit) ->setWorkflow(!$can_edit)); return $curtain; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceSourceEditController.php
src/applications/nuance/controller/NuanceSourceEditController.php
<?php final class NuanceSourceEditController extends NuanceSourceController { public function handleRequest(AphrontRequest $request) { $engine = id(new NuanceSourceEditEngine()) ->setController($this); $id = $request->getURIData('id'); if (!$id) { $this->requireApplicationCapability( NuanceSourceManageCapability::CAPABILITY); $cancel_uri = $this->getApplicationURI('source/'); $map = NuanceSourceDefinition::getAllDefinitions(); $source_type = $request->getStr('sourceType'); if (!isset($map[$source_type])) { return $this->buildSourceTypeResponse($cancel_uri); } $engine ->setSourceDefinition($map[$source_type]) ->addContextParameter('sourceType', $source_type); } return $engine->buildResponse(); } private function buildSourceTypeResponse($cancel_uri) { $viewer = $this->getViewer(); $request = $this->getRequest(); $map = NuanceSourceDefinition::getAllDefinitions(); $errors = array(); $e_source = null; if ($request->isFormPost()) { $errors[] = pht('You must choose a source type.'); $e_source = pht('Required'); } $source_types = id(new AphrontFormRadioButtonControl()) ->setName('sourceType') ->setLabel(pht('Source Type')); foreach ($map as $type => $definition) { $source_types->addButton( $type, $definition->getName(), $definition->getSourceDescription()); } $form = id(new AphrontFormView()) ->setUser($viewer) ->appendChild($source_types) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue(pht('Continue')) ->addCancelButton($cancel_uri)); $box = id(new PHUIObjectBoxView()) ->setFormErrors($errors) ->setHeaderText(pht('Choose Source Type')) ->appendChild($form); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Sources'), $cancel_uri); $crumbs->addTextCrumb(pht('New')); return $this->newPage() ->setTitle(pht('Choose Source Type')) ->setCrumbs($crumbs) ->appendChild($box); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceQueueListController.php
src/applications/nuance/controller/NuanceQueueListController.php
<?php final class NuanceQueueListController extends NuanceQueueController { public function handleRequest(AphrontRequest $request) { return id(new NuanceQueueSearchEngine()) ->setController($this) ->buildResponse(); } protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); id(new NuanceQueueEditEngine()) ->setViewer($this->getViewer()) ->addActionToCrumbs($crumbs); return $crumbs; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceConsoleController.php
src/applications/nuance/controller/NuanceConsoleController.php
<?php final class NuanceConsoleController extends NuanceController { public function shouldAllowPublic() { return true; } public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); $menu = id(new PHUIObjectItemListView()) ->setUser($viewer); $menu->addItem( id(new PHUIObjectItemView()) ->setHeader(pht('Queues')) ->setHref($this->getApplicationURI('queue/')) ->setImageIcon('fa-align-left') ->addAttribute(pht('Manage Nuance queues.'))); $menu->addItem( id(new PHUIObjectItemView()) ->setHeader(pht('Sources')) ->setHref($this->getApplicationURI('source/')) ->setImageIcon('fa-filter') ->addAttribute(pht('Manage Nuance sources.'))); $menu->addItem( id(new PHUIObjectItemView()) ->setHeader(pht('Items')) ->setHref($this->getApplicationURI('item/')) ->setImageIcon('fa-clone') ->addAttribute(pht('Manage Nuance items.'))); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Console')); $crumbs->setBorder(true); $box = id(new PHUIObjectBoxView()) ->setObjectList($menu); $header = id(new PHUIHeaderView()) ->setHeader(pht('Nuance Console')) ->setHeaderIcon('fa-fax'); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setFooter(array( $box, )); return $this->newPage() ->setTitle(pht('Nuance Console')) ->setCrumbs($crumbs) ->appendChild($view); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceQueueController.php
src/applications/nuance/controller/NuanceQueueController.php
<?php abstract class NuanceQueueController extends NuanceController { public function buildApplicationMenu() { return $this->newApplicationMenu() ->setSearchEngine(new NuanceQueueSearchEngine()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/controller/NuanceItemListController.php
src/applications/nuance/controller/NuanceItemListController.php
<?php final class NuanceItemListController extends NuanceItemController { public function handleRequest(AphrontRequest $request) { return id(new NuanceItemSearchEngine()) ->setController($this) ->buildResponse(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceQueueTransactionComment.php
src/applications/nuance/storage/NuanceQueueTransactionComment.php
<?php final class NuanceQueueTransactionComment extends PhabricatorApplicationTransactionComment { public function getApplicationTransactionObject() { return new NuanceQueueTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceQueue.php
src/applications/nuance/storage/NuanceQueue.php
<?php final class NuanceQueue extends NuanceDAO implements PhabricatorPolicyInterface, PhabricatorApplicationTransactionInterface { protected $name; protected $mailKey; protected $viewPolicy; protected $editPolicy; protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'text255?', 'mailKey' => 'bytes20', ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( NuanceQueuePHIDType::TYPECONST); } public static function initializeNewQueue() { return id(new self()) ->setViewPolicy(PhabricatorPolicies::POLICY_USER) ->setEditPolicy(PhabricatorPolicies::POLICY_USER); } public function save() { if (!$this->getMailKey()) { $this->setMailKey(Filesystem::readRandomCharacters(20)); } return parent::save(); } public function getURI() { return '/nuance/queue/view/'.$this->getID().'/'; } public function getWorkURI() { return '/nuance/queue/work/'.$this->getID().'/'; } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return $this->getViewPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return $this->getEditPolicy(); } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new NuanceQueueEditor(); } public function getApplicationTransactionTemplate() { return new NuanceQueueTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceItemTransactionComment.php
src/applications/nuance/storage/NuanceItemTransactionComment.php
<?php final class NuanceItemTransactionComment extends PhabricatorApplicationTransactionComment { public function getApplicationTransactionObject() { return new NuanceItemTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceSourceTransactionComment.php
src/applications/nuance/storage/NuanceSourceTransactionComment.php
<?php final class NuanceSourceTransactionComment extends PhabricatorApplicationTransactionComment { public function getApplicationTransactionObject() { return new NuanceSourceTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceDAO.php
src/applications/nuance/storage/NuanceDAO.php
<?php abstract class NuanceDAO extends PhabricatorLiskDAO { public function getApplicationName() { return 'nuance'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceSourceTransaction.php
src/applications/nuance/storage/NuanceSourceTransaction.php
<?php final class NuanceSourceTransaction extends NuanceTransaction { public function getApplicationTransactionType() { return NuanceSourcePHIDType::TYPECONST; } public function getApplicationTransactionCommentObject() { return new NuanceSourceTransactionComment(); } public function getBaseTransactionClass() { return 'NuanceSourceTransactionType'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceSourceNameNgrams.php
src/applications/nuance/storage/NuanceSourceNameNgrams.php
<?php final class NuanceSourceNameNgrams extends PhabricatorSearchNgrams { public function getNgramKey() { return 'sourcename'; } public function getColumnName() { return 'name'; } public function getApplicationName() { return 'nuance'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceQueueTransaction.php
src/applications/nuance/storage/NuanceQueueTransaction.php
<?php final class NuanceQueueTransaction extends NuanceTransaction { public function getApplicationTransactionType() { return NuanceQueuePHIDType::TYPECONST; } public function getApplicationTransactionCommentObject() { return new NuanceQueueTransactionComment(); } public function getBaseTransactionClass() { return 'NuanceQueueTransactionType'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceItemTransaction.php
src/applications/nuance/storage/NuanceItemTransaction.php
<?php final class NuanceItemTransaction extends NuanceTransaction { const PROPERTY_KEY = 'property.key'; public function getApplicationTransactionType() { return NuanceItemPHIDType::TYPECONST; } public function getApplicationTransactionCommentObject() { return new NuanceItemTransactionComment(); } public function getBaseTransactionClass() { return 'NuanceItemTransactionType'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceItem.php
src/applications/nuance/storage/NuanceItem.php
<?php final class NuanceItem extends NuanceDAO implements PhabricatorPolicyInterface, PhabricatorApplicationTransactionInterface { const STATUS_IMPORTING = 'importing'; const STATUS_ROUTING = 'routing'; const STATUS_OPEN = 'open'; const STATUS_CLOSED = 'closed'; protected $status; protected $ownerPHID; protected $requestorPHID; protected $sourcePHID; protected $queuePHID; protected $itemType; protected $itemKey; protected $itemContainerKey; protected $data = array(); protected $mailKey; private $queue = self::ATTACHABLE; private $source = self::ATTACHABLE; private $implementation = self::ATTACHABLE; public static function initializeNewItem($item_type) { // TODO: Validate that the type is valid, and construct and attach it. return id(new NuanceItem()) ->setItemType($item_type) ->setStatus(self::STATUS_OPEN); } protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'data' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'ownerPHID' => 'phid?', 'requestorPHID' => 'phid?', 'queuePHID' => 'phid?', 'itemType' => 'text64', 'itemKey' => 'text64?', 'itemContainerKey' => 'text64?', 'status' => 'text32', 'mailKey' => 'bytes20', ), self::CONFIG_KEY_SCHEMA => array( 'key_source' => array( 'columns' => array('sourcePHID', 'status'), ), 'key_owner' => array( 'columns' => array('ownerPHID', 'status'), ), 'key_requestor' => array( 'columns' => array('requestorPHID', 'status'), ), 'key_queue' => array( 'columns' => array('queuePHID', 'status'), ), 'key_container' => array( 'columns' => array('sourcePHID', 'itemContainerKey'), ), 'key_item' => array( 'columns' => array('sourcePHID', 'itemKey'), 'unique' => true, ), ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( NuanceItemPHIDType::TYPECONST); } public function save() { if (!$this->getMailKey()) { $this->setMailKey(Filesystem::readRandomCharacters(20)); } return parent::save(); } public function getURI() { return '/nuance/item/view/'.$this->getID().'/'; } public function getSource() { return $this->assertAttached($this->source); } public function attachSource(NuanceSource $source) { $this->source = $source; } public function getItemProperty($key, $default = null) { return idx($this->data, $key, $default); } public function setItemProperty($key, $value) { $this->data[$key] = $value; return $this; } public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { // TODO - this should be based on the queues the item currently resides in return PhabricatorPolicies::POLICY_USER; } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { // TODO - requestors should get auto access too! return $viewer->getPHID() == $this->ownerPHID; } public function describeAutomaticCapability($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return pht('Owners of an item can always view it.'); case PhabricatorPolicyCapability::CAN_EDIT: return pht('Owners of an item can always edit it.'); } return null; } public function getDisplayName() { return $this->getImplementation()->getItemDisplayName($this); } public function scheduleUpdate() { PhabricatorWorker::scheduleTask( 'NuanceItemUpdateWorker', array( 'itemPHID' => $this->getPHID(), ), array( 'objectPHID' => $this->getPHID(), )); } public function issueCommand( $author_phid, $command, array $parameters = array()) { $command = id(NuanceItemCommand::initializeNewCommand()) ->setItemPHID($this->getPHID()) ->setAuthorPHID($author_phid) ->setCommand($command) ->setParameters($parameters) ->save(); $this->scheduleUpdate(); return $this; } public function getImplementation() { return $this->assertAttached($this->implementation); } public function attachImplementation(NuanceItemType $type) { $this->implementation = $type; return $this; } public function getQueue() { return $this->assertAttached($this->queue); } public function attachQueue(NuanceQueue $queue = null) { $this->queue = $queue; return $this; } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new NuanceItemEditor(); } public function getApplicationTransactionTemplate() { return new NuanceItemTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceSource.php
src/applications/nuance/storage/NuanceSource.php
<?php final class NuanceSource extends NuanceDAO implements PhabricatorApplicationTransactionInterface, PhabricatorPolicyInterface, PhabricatorNgramsInterface { protected $name; protected $type; protected $data = array(); protected $mailKey; protected $viewPolicy; protected $editPolicy; protected $defaultQueuePHID; protected $isDisabled; private $definition = self::ATTACHABLE; protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'data' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'name' => 'sort255', 'type' => 'text32', 'mailKey' => 'bytes20', 'isDisabled' => 'bool', ), self::CONFIG_KEY_SCHEMA => array( 'key_type' => array( 'columns' => array('type', 'dateModified'), ), ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID(NuanceSourcePHIDType::TYPECONST); } public function save() { if (!$this->getMailKey()) { $this->setMailKey(Filesystem::readRandomCharacters(20)); } return parent::save(); } public function getURI() { return '/nuance/source/view/'.$this->getID().'/'; } public static function initializeNewSource( PhabricatorUser $actor, NuanceSourceDefinition $definition) { $app = id(new PhabricatorApplicationQuery()) ->setViewer($actor) ->withClasses(array('PhabricatorNuanceApplication')) ->executeOne(); $view_policy = $app->getPolicy( NuanceSourceDefaultViewCapability::CAPABILITY); $edit_policy = $app->getPolicy( NuanceSourceDefaultEditCapability::CAPABILITY); return id(new NuanceSource()) ->setViewPolicy($view_policy) ->setEditPolicy($edit_policy) ->setType($definition->getSourceTypeConstant()) ->attachDefinition($definition) ->setIsDisabled(0); } public function getDefinition() { return $this->assertAttached($this->definition); } public function attachDefinition(NuanceSourceDefinition $definition) { $this->definition = $definition; return $this; } public function getSourceProperty($key, $default = null) { return idx($this->data, $key, $default); } public function setSourceProperty($key, $value) { $this->data[$key] = $value; return $this; } /* -( PhabricatorApplicationTransactionInterface )------------------------- */ public function getApplicationTransactionEditor() { return new NuanceSourceEditor(); } public function getApplicationTransactionTemplate() { return new NuanceSourceTransaction(); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return $this->getViewPolicy(); case PhabricatorPolicyCapability::CAN_EDIT: return $this->getEditPolicy(); } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } /* -( PhabricatorNgramsInterface )----------------------------------------- */ public function newNgrams() { return array( id(new NuanceSourceNameNgrams()) ->setValue($this->getName()), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceImportCursorData.php
src/applications/nuance/storage/NuanceImportCursorData.php
<?php final class NuanceImportCursorData extends NuanceDAO implements PhabricatorPolicyInterface { protected $sourcePHID; protected $cursorKey; protected $cursorType; protected $properties = array(); protected function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'properties' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'cursorType' => 'text32', 'cursorKey' => 'text32', ), self::CONFIG_KEY_SCHEMA => array( 'key_source' => array( 'columns' => array('sourcePHID', 'cursorKey'), 'unique' => true, ), ), ) + parent::getConfiguration(); } public function generatePHID() { return PhabricatorPHID::generateNewPHID( NuanceImportCursorPHIDType::TYPECONST); } public function getCursorProperty($key, $default = null) { return idx($this->properties, $key, $default); } public function setCursorProperty($key, $value) { $this->properties[$key] = $value; return $this; } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::POLICY_USER; } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceTransaction.php
src/applications/nuance/storage/NuanceTransaction.php
<?php abstract class NuanceTransaction extends PhabricatorModularTransaction { public function getApplicationName() { return 'nuance'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceItemCommand.php
src/applications/nuance/storage/NuanceItemCommand.php
<?php final class NuanceItemCommand extends NuanceDAO implements PhabricatorPolicyInterface { const STATUS_ISSUED = 'issued'; const STATUS_EXECUTING = 'executing'; const STATUS_DONE = 'done'; const STATUS_FAILED = 'failed'; protected $itemPHID; protected $authorPHID; protected $queuePHID; protected $command; protected $status; protected $parameters = array(); public static function initializeNewCommand() { return id(new self()) ->setStatus(self::STATUS_ISSUED); } protected function getConfiguration() { return array( self::CONFIG_SERIALIZATION => array( 'parameters' => self::SERIALIZATION_JSON, ), self::CONFIG_COLUMN_SCHEMA => array( 'command' => 'text64', 'status' => 'text64', 'queuePHID' => 'phid?', ), self::CONFIG_KEY_SCHEMA => array( 'key_pending' => array( 'columns' => array('itemPHID', 'status'), ), ), ) + parent::getConfiguration(); } public static function getStatusMap() { return array( self::STATUS_ISSUED => array( 'name' => pht('Issued'), 'icon' => 'fa-clock-o', 'color' => 'bluegrey', ), self::STATUS_EXECUTING => array( 'name' => pht('Executing'), 'icon' => 'fa-play', 'color' => 'green', ), self::STATUS_DONE => array( 'name' => pht('Done'), 'icon' => 'fa-check', 'color' => 'blue', ), self::STATUS_FAILED => array( 'name' => pht('Failed'), 'icon' => 'fa-times', 'color' => 'red', ), ); } private function getStatusSpec() { $map = self::getStatusMap(); return idx($map, $this->getStatus(), array()); } public function getStatusIcon() { $spec = $this->getStatusSpec(); return idx($spec, 'icon', 'fa-question'); } public function getStatusColor() { $spec = $this->getStatusSpec(); return idx($spec, 'color', 'indigo'); } public function getStatusName() { $spec = $this->getStatusSpec(); return idx($spec, 'name', $this->getStatus()); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, ); } public function getPolicy($capability) { return PhabricatorPolicies::getMostOpenPolicy(); } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/storage/NuanceSchemaSpec.php
src/applications/nuance/storage/NuanceSchemaSpec.php
<?php final class NuanceSchemaSpec extends PhabricatorConfigSchemaSpec { public function buildSchemata() { $this->buildEdgeSchemata(new NuanceItem()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/management/NuanceManagementImportWorkflow.php
src/applications/nuance/management/NuanceManagementImportWorkflow.php
<?php final class NuanceManagementImportWorkflow extends NuanceManagementWorkflow { protected function didConstruct() { $this ->setName('import') ->setExamples('**import** --source __source__ [__options__]') ->setSynopsis(pht('Import data from a source.')) ->setArguments( array( array( 'name' => 'source', 'param' => 'source', 'help' => pht('Choose which source to import.'), ), array( 'name' => 'cursor', 'param' => 'cursor', 'help' => pht('Import only a particular cursor.'), ), )); } public function execute(PhutilArgumentParser $args) { $source = $this->loadSource($args, 'source'); $definition = $source->getDefinition() ->setViewer($this->getViewer()) ->setSource($source); if (!$definition->hasImportCursors()) { throw new PhutilArgumentUsageException( pht( 'This source ("%s") does not expose import cursors.', $source->getName())); } $cursors = $definition->getImportCursors(); if (!$cursors) { throw new PhutilArgumentUsageException( pht( 'This source ("%s") does not have any import cursors.', $source->getName())); } $select = $args->getArg('cursor'); if (strlen($select)) { if (empty($cursors[$select])) { throw new PhutilArgumentUsageException( pht( 'This source ("%s") does not have a "%s" cursor. Available '. 'cursors: %s.', $source->getName(), $select, implode(', ', array_keys($cursors)))); } else { echo tsprintf( "%s\n", pht( 'Importing cursor "%s" only.', $select)); $cursors = array_select_keys($cursors, array($select)); } } else { echo tsprintf( "%s\n", pht( 'Importing all cursors: %s.', implode(', ', array_keys($cursors)))); echo tsprintf( "%s\n", pht('(Use --cursor to import only a particular cursor.)')); } foreach ($cursors as $cursor) { $cursor->importFromSource(); } 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/nuance/management/NuanceManagementUpdateWorkflow.php
src/applications/nuance/management/NuanceManagementUpdateWorkflow.php
<?php final class NuanceManagementUpdateWorkflow extends NuanceManagementWorkflow { protected function didConstruct() { $this ->setName('update') ->setExamples('**update** --item __item__ [__options__]') ->setSynopsis(pht('Update or route an item.')) ->setArguments( array( array( 'name' => 'item', 'param' => 'item', 'help' => pht('Choose which item to route.'), ), )); } public function execute(PhutilArgumentParser $args) { $item = $this->loadItem($args, 'item'); PhabricatorWorker::setRunAllTasksInProcess(true); $item->scheduleUpdate(); 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/nuance/management/NuanceManagementWorkflow.php
src/applications/nuance/management/NuanceManagementWorkflow.php
<?php abstract class NuanceManagementWorkflow extends PhabricatorManagementWorkflow { protected function loadSource(PhutilArgumentParser $argv, $key) { $source = $argv->getArg($key); if (!strlen($source)) { throw new PhutilArgumentUsageException( pht( 'Specify a source with %s.', '--'.$key)); } $query = id(new NuanceSourceQuery()) ->setViewer($this->getViewer()) ->setRaisePolicyExceptions(true); $type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN; if (ctype_digit($source)) { $kind = 'id'; $query->withIDs(array($source)); } else if (phid_get_type($source) !== $type_unknown) { $kind = 'phid'; $query->withPHIDs($source); } else { $kind = 'name'; $query->withNameNgrams($source); } $sources = $query->execute(); if (!$sources) { switch ($kind) { case 'id': $message = pht( 'No source exists with ID "%s".', $source); break; case 'phid': $message = pht( 'No source exists with PHID "%s".', $source); break; default: $message = pht( 'No source exists with a name matching "%s".', $source); break; } throw new PhutilArgumentUsageException($message); } else if (count($sources) > 1) { $message = pht( 'More than one source matches "%s". Choose a narrower query, or '. 'use an ID or PHID to select a source. Matching sources: %s.', $source, implode(', ', mpull($sources, 'getName'))); throw new PhutilArgumentUsageException($message); } return head($sources); } protected function loadITem(PhutilArgumentParser $argv, $key) { $item = $argv->getArg($key); if (!strlen($item)) { throw new PhutilArgumentUsageException( pht( 'Specify a item with %s.', '--'.$key)); } $query = id(new NuanceItemQuery()) ->setViewer($this->getViewer()) ->setRaisePolicyExceptions(true); $type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN; if (ctype_digit($item)) { $kind = 'id'; $query->withIDs(array($item)); } else if (phid_get_type($item) !== $type_unknown) { $kind = 'phid'; $query->withPHIDs($item); } else { throw new PhutilArgumentUsageException( pht( 'Specify the ID or PHID of an item to update. Parameter "%s" '. 'is not an ID or PHID.', $item)); } $items = $query->execute(); if (!$items) { switch ($kind) { case 'id': $message = pht( 'No item exists with ID "%s".', $item); break; case 'phid': $message = pht( 'No item exists with PHID "%s".', $item); break; } throw new PhutilArgumentUsageException($message); } return head($items); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/worker/NuanceWorker.php
src/applications/nuance/worker/NuanceWorker.php
<?php abstract class NuanceWorker extends PhabricatorWorker { protected function getViewer() { return PhabricatorUser::getOmnipotentUser(); } protected function loadItem($item_phid) { $item = id(new NuanceItemQuery()) ->setViewer($this->getViewer()) ->withPHIDs(array($item_phid)) ->executeOne(); if (!$item) { throw new PhabricatorWorkerPermanentFailureException( pht( 'There is no Nuance item with PHID "%s".', $item_phid)); } return $item; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/worker/NuanceItemUpdateWorker.php
src/applications/nuance/worker/NuanceItemUpdateWorker.php
<?php final class NuanceItemUpdateWorker extends NuanceWorker { protected function doWork() { $item_phid = $this->getTaskDataValue('itemPHID'); $lock = $this->newLock($item_phid); $lock->lock(1); try { $item = $this->loadItem($item_phid); $this->updateItem($item); $this->routeItem($item); $this->applyCommands($item); } catch (Exception $ex) { $lock->unlock(); throw $ex; } $lock->unlock(); } private function updateItem(NuanceItem $item) { $impl = $item->getImplementation(); if (!$impl->canUpdateItems()) { return null; } $viewer = $this->getViewer(); $impl->setViewer($viewer); $impl->updateItem($item); } private function routeItem(NuanceItem $item) { $status = $item->getStatus(); if ($status != NuanceItem::STATUS_ROUTING) { return; } $source = $item->getSource(); // For now, always route items into the source's default queue. $item ->setQueuePHID($source->getDefaultQueuePHID()) ->setStatus(NuanceItem::STATUS_OPEN) ->save(); } private function applyCommands(NuanceItem $item) { $viewer = $this->getViewer(); $commands = id(new NuanceItemCommandQuery()) ->setViewer($viewer) ->withItemPHIDs(array($item->getPHID())) ->withStatuses( array( NuanceItemCommand::STATUS_ISSUED, )) ->execute(); $commands = msort($commands, 'getID'); $this->executeCommandList($item, $commands); } public function executeCommands(NuanceItem $item, array $commands) { if (!$commands) { return true; } $item_phid = $item->getPHID(); $viewer = $this->getViewer(); $lock = $this->newLock($item_phid); try { $lock->lock(1); } catch (PhutilLockException $ex) { return false; } try { $item = $this->loadItem($item_phid); // Reload commands now that we have a lock, to make sure we don't // execute any commands twice by mistake. $commands = id(new NuanceItemCommandQuery()) ->setViewer($viewer) ->withIDs(mpull($commands, 'getID')) ->execute(); $this->executeCommandList($item, $commands); } catch (Exception $ex) { $lock->unlock(); throw $ex; } $lock->unlock(); return true; } private function executeCommandList(NuanceItem $item, array $commands) { $viewer = $this->getViewer(); $executors = NuanceCommandImplementation::getAllCommands(); foreach ($commands as $command) { if ($command->getItemPHID() !== $item->getPHID()) { throw new Exception( pht('Trying to apply a command to the wrong item!')); } if ($command->getStatus() !== NuanceItemCommand::STATUS_ISSUED) { // Never execute commands which have already been issued. continue; } $command ->setStatus(NuanceItemCommand::STATUS_EXECUTING) ->save(); try { $command_key = $command->getCommand(); $executor = idx($executors, $command_key); if (!$executor) { throw new Exception( pht( 'Unable to execute command "%s": this command does not have '. 'a recognized command implementation.', $command_key)); } $executor = clone $executor; $executor ->setActor($viewer) ->applyCommand($item, $command); $command ->setStatus(NuanceItemCommand::STATUS_DONE) ->save(); } catch (Exception $ex) { $command ->setStatus(NuanceItemCommand::STATUS_FAILED) ->save(); throw $ex; } } } private function newLock($item_phid) { $hash = PhabricatorHash::digestForIndex($item_phid); $lock_key = "nuance.item.{$hash}"; return PhabricatorGlobalLock::newLock($lock_key); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceImportCursorDataQuery.php
src/applications/nuance/query/NuanceImportCursorDataQuery.php
<?php final class NuanceImportCursorDataQuery extends NuanceQuery { private $ids; private $phids; private $sourcePHIDs; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } public function withSourcePHIDs(array $source_phids) { $this->sourcePHIDs = $source_phids; return $this; } public function newResultObject() { return new NuanceImportCursorData(); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->sourcePHIDs !== null) { $where[] = qsprintf( $conn, 'sourcePHID IN (%Ls)', $this->sourcePHIDs); } if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'phid IN (%Ls)', $this->phids); } return $where; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceSourceTransactionQuery.php
src/applications/nuance/query/NuanceSourceTransactionQuery.php
<?php final class NuanceSourceTransactionQuery extends PhabricatorApplicationTransactionQuery { public function getTemplateApplicationTransaction() { return new NuanceSourceTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceQuery.php
src/applications/nuance/query/NuanceQuery.php
<?php abstract class NuanceQuery extends PhabricatorCursorPagedPolicyAwareQuery { public function getQueryApplicationClass() { return 'PhabricatorNuanceApplication'; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceItemTransactionQuery.php
src/applications/nuance/query/NuanceItemTransactionQuery.php
<?php final class NuanceItemTransactionQuery extends PhabricatorApplicationTransactionQuery { public function getTemplateApplicationTransaction() { return new NuanceItemTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceItemQuery.php
src/applications/nuance/query/NuanceItemQuery.php
<?php final class NuanceItemQuery extends NuanceQuery { private $ids; private $phids; private $sourcePHIDs; private $queuePHIDs; private $itemTypes; private $itemKeys; private $containerKeys; private $statuses; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } public function withSourcePHIDs(array $source_phids) { $this->sourcePHIDs = $source_phids; return $this; } public function withQueuePHIDs(array $queue_phids) { $this->queuePHIDs = $queue_phids; return $this; } public function withItemTypes(array $item_types) { $this->itemTypes = $item_types; return $this; } public function withItemKeys(array $item_keys) { $this->itemKeys = $item_keys; return $this; } public function withStatuses(array $statuses) { $this->statuses = $statuses; return $this; } public function withItemContainerKeys(array $container_keys) { $this->containerKeys = $container_keys; return $this; } public function newResultObject() { return new NuanceItem(); } protected function willFilterPage(array $items) { $viewer = $this->getViewer(); $source_phids = mpull($items, 'getSourcePHID'); $sources = id(new NuanceSourceQuery()) ->setViewer($viewer) ->withPHIDs($source_phids) ->execute(); $sources = mpull($sources, null, 'getPHID'); foreach ($items as $key => $item) { $source = idx($sources, $item->getSourcePHID()); if (!$source) { $this->didRejectResult($items[$key]); unset($items[$key]); continue; } $item->attachSource($source); } $type_map = NuanceItemType::getAllItemTypes(); foreach ($items as $key => $item) { $type = idx($type_map, $item->getItemType()); if (!$type) { $this->didRejectResult($items[$key]); unset($items[$key]); continue; } $item->attachImplementation($type); } $queue_phids = array(); foreach ($items as $item) { $queue_phid = $item->getQueuePHID(); if ($queue_phid) { $queue_phids[$queue_phid] = $queue_phid; } } if ($queue_phids) { $queues = id(new NuanceQueueQuery()) ->setViewer($viewer) ->withPHIDs($queue_phids) ->execute(); $queues = mpull($queues, null, 'getPHID'); } else { $queues = array(); } foreach ($items as $key => $item) { $queue_phid = $item->getQueuePHID(); if (!$queue_phid) { $item->attachQueue(null); continue; } $queue = idx($queues, $queue_phid); if (!$queue) { unset($items[$key]); $this->didRejectResult($item); continue; } $item->attachQueue($queue); } return $items; } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->sourcePHIDs !== null) { $where[] = qsprintf( $conn, 'sourcePHID IN (%Ls)', $this->sourcePHIDs); } if ($this->queuePHIDs !== null) { $where[] = qsprintf( $conn, 'queuePHID IN (%Ls)', $this->queuePHIDs); } if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'phid IN (%Ls)', $this->phids); } if ($this->statuses !== null) { $where[] = qsprintf( $conn, 'status IN (%Ls)', $this->statuses); } if ($this->itemTypes !== null) { $where[] = qsprintf( $conn, 'itemType IN (%Ls)', $this->itemTypes); } if ($this->itemKeys !== null) { $where[] = qsprintf( $conn, 'itemKey IN (%Ls)', $this->itemKeys); } if ($this->containerKeys !== null) { $where[] = qsprintf( $conn, 'itemContainerKey IN (%Ls)', $this->containerKeys); } return $where; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceQueueSearchEngine.php
src/applications/nuance/query/NuanceQueueSearchEngine.php
<?php final class NuanceQueueSearchEngine extends PhabricatorApplicationSearchEngine { public function getApplicationClassName() { return 'PhabricatorNuanceApplication'; } public function getResultTypeDescription() { return pht('Nuance Queues'); } public function newQuery() { return new NuanceQueueQuery(); } protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); return $query; } protected function buildCustomSearchFields() { return array(); } protected function getURI($path) { return '/nuance/queue/'.$path; } protected function getBuiltinQueryNames() { $names = array( 'all' => pht('All Queues'), ); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $queues, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($queues, 'NuanceQueue'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); $list->setUser($viewer); foreach ($queues as $queue) { $item = id(new PHUIObjectItemView()) ->setObjectName(pht('Queue %d', $queue->getID())) ->setHeader($queue->getName()) ->setHref($queue->getURI()); $list->addItem($item); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No queues found.')); 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/nuance/query/NuanceSourceQuery.php
src/applications/nuance/query/NuanceSourceQuery.php
<?php final class NuanceSourceQuery extends NuanceQuery { private $ids; private $phids; private $types; private $isDisabled; private $hasCursors; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } public function withTypes($types) { $this->types = $types; return $this; } public function withIsDisabled($disabled) { $this->isDisabled = $disabled; return $this; } public function withHasImportCursors($has_cursors) { $this->hasCursors = $has_cursors; return $this; } public function withNameNgrams($ngrams) { return $this->withNgramsConstraint( new NuanceSourceNameNgrams(), $ngrams); } public function newResultObject() { return new NuanceSource(); } protected function getPrimaryTableAlias() { return 'source'; } protected function willFilterPage(array $sources) { $all_types = NuanceSourceDefinition::getAllDefinitions(); foreach ($sources as $key => $source) { $definition = idx($all_types, $source->getType()); if (!$definition) { $this->didRejectResult($source); unset($sources[$key]); continue; } $source->attachDefinition($definition); } return $sources; } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->types !== null) { $where[] = qsprintf( $conn, 'source.type IN (%Ls)', $this->types); } if ($this->ids !== null) { $where[] = qsprintf( $conn, 'source.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'source.phid IN (%Ls)', $this->phids); } if ($this->isDisabled !== null) { $where[] = qsprintf( $conn, 'source.isDisabled = %d', (int)$this->isDisabled); } if ($this->hasCursors !== null) { $cursor_types = array(); $definitions = NuanceSourceDefinition::getAllDefinitions(); foreach ($definitions as $key => $definition) { if ($definition->hasImportCursors()) { $cursor_types[] = $key; } } if ($this->hasCursors) { if (!$cursor_types) { throw new PhabricatorEmptyQueryException(); } else { $where[] = qsprintf( $conn, 'source.type IN (%Ls)', $cursor_types); } } else { if (!$cursor_types) { // Apply no constraint. } else { $where[] = qsprintf( $conn, 'source.type NOT IN (%Ls)', $cursor_types); } } } return $where; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceQueueTransactionQuery.php
src/applications/nuance/query/NuanceQueueTransactionQuery.php
<?php final class NuanceQueueTransactionQuery extends PhabricatorApplicationTransactionQuery { public function getTemplateApplicationTransaction() { return new NuanceQueueTransaction(); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceItemSearchEngine.php
src/applications/nuance/query/NuanceItemSearchEngine.php
<?php final class NuanceItemSearchEngine extends PhabricatorApplicationSearchEngine { public function getApplicationClassName() { return 'PhabricatorNuanceApplication'; } public function getResultTypeDescription() { return pht('Nuance Items'); } public function newQuery() { return new NuanceItemQuery(); } protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); return $query; } protected function buildCustomSearchFields() { return array( ); } protected function getURI($path) { return '/nuance/item/'.$path; } protected function getBuiltinQueryNames() { $names = array( 'all' => pht('All Items'), ); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $items, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($items, 'NuanceItem'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); $list->setUser($viewer); foreach ($items as $item) { $impl = $item->getImplementation(); $view = id(new PHUIObjectItemView()) ->setObjectName(pht('Item %d', $item->getID())) ->setHeader($item->getDisplayName()) ->setHref($item->getURI()); $view->addIcon( $impl->getItemTypeDisplayIcon(), $impl->getItemTypeDisplayName()); $queue = $item->getQueue(); if ($queue) { $view->addAttribute( phutil_tag( 'a', array( 'href' => $queue->getURI(), ), $queue->getName())); } else { $view->addAttribute(phutil_tag('em', array(), pht('Not in Queue'))); } $list->addItem($view); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No items found.')); 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/nuance/query/NuanceItemCommandQuery.php
src/applications/nuance/query/NuanceItemCommandQuery.php
<?php final class NuanceItemCommandQuery extends NuanceQuery { private $ids; private $itemPHIDs; private $statuses; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withItemPHIDs(array $item_phids) { $this->itemPHIDs = $item_phids; return $this; } public function withStatuses(array $statuses) { $this->statuses = $statuses; return $this; } public function newResultObject() { return new NuanceItemCommand(); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); } if ($this->itemPHIDs !== null) { $where[] = qsprintf( $conn, 'itemPHID IN (%Ls)', $this->itemPHIDs); } if ($this->statuses !== null) { $where[] = qsprintf( $conn, 'status IN (%Ls)', $this->statuses); } return $where; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/query/NuanceSourceSearchEngine.php
src/applications/nuance/query/NuanceSourceSearchEngine.php
<?php final class NuanceSourceSearchEngine extends PhabricatorApplicationSearchEngine { public function getApplicationClassName() { return 'PhabricatorNuanceApplication'; } public function getResultTypeDescription() { return pht('Nuance Sources'); } public function newQuery() { return new NuanceSourceQuery(); } protected function buildQueryFromParameters(array $map) { $query = $this->newQuery(); if ($map['match'] !== null) { $query->withNameNgrams($map['match']); } return $query; } protected function buildCustomSearchFields() { return array( id(new PhabricatorSearchTextField()) ->setLabel(pht('Name Contains')) ->setKey('match') ->setDescription(pht('Search for sources by name substring.')), ); } protected function getURI($path) { return '/nuance/source/'.$path; } protected function getBuiltinQueryNames() { $names = array( 'all' => pht('All Sources'), ); return $names; } public function buildSavedQueryFromBuiltin($query_key) { $query = $this->newSavedQuery(); $query->setQueryKey($query_key); switch ($query_key) { case 'all': return $query; } return parent::buildSavedQueryFromBuiltin($query_key); } protected function renderResultList( array $sources, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($sources, 'NuanceSource'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); $list->setUser($viewer); foreach ($sources as $source) { $item = id(new PHUIObjectItemView()) ->setObjectName(pht('Source %d', $source->getID())) ->setHeader($source->getName()) ->setHref($source->getURI()); $item->addIcon('none', $source->getType()); $list->addItem($item); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No sources found.')); 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/nuance/query/NuanceQueueQuery.php
src/applications/nuance/query/NuanceQueueQuery.php
<?php final class NuanceQueueQuery extends NuanceQuery { private $ids; private $phids; public function withIDs(array $ids) { $this->ids = $ids; return $this; } public function withPHIDs(array $phids) { $this->phids = $phids; return $this; } public function newResultObject() { return new NuanceQueue(); } protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { $where = parent::buildWhereClauseParts($conn); if ($this->ids !== null) { $where[] = qsprintf( $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( $conn, 'phid IN (%Ls)', $this->phids); } return $where; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/contentsource/NuanceContentSource.php
src/applications/nuance/contentsource/NuanceContentSource.php
<?php final class NuanceContentSource extends PhabricatorContentSource { const SOURCECONST = 'nuance'; public function getSourceName() { return pht('Nuance'); } public function getSourceDescription() { return pht('Content imported via Nuance.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/command/NuanceTrashCommand.php
src/applications/nuance/command/NuanceTrashCommand.php
<?php final class NuanceTrashCommand extends NuanceCommandImplementation { const COMMANDKEY = 'trash'; public function getCommandName() { return pht('Throw in Trash'); } public function canApplyToItem(NuanceItem $item) { $type = $item->getImplementation(); return ($type instanceof NuanceFormItemType); } public function canApplyImmediately( NuanceItem $item, NuanceItemCommand $command) { return true; } protected function executeCommand( NuanceItem $item, NuanceItemCommand $command) { $this->newStatusTransaction(NuanceItem::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/nuance/command/NuanceCommandImplementation.php
src/applications/nuance/command/NuanceCommandImplementation.php
<?php abstract class NuanceCommandImplementation extends Phobject { private $actor; private $transactionQueue = array(); final public function setActor(PhabricatorUser $actor) { $this->actor = $actor; return $this; } final public function getActor() { return $this->actor; } abstract public function getCommandName(); abstract public function canApplyToItem(NuanceItem $item); public function canApplyImmediately( NuanceItem $item, NuanceItemCommand $command) { return false; } abstract protected function executeCommand( NuanceItem $item, NuanceItemCommand $command); final public function applyCommand( NuanceItem $item, NuanceItemCommand $command) { $command_key = $command->getCommand(); $implementation_key = $this->getCommandKey(); if ($command_key !== $implementation_key) { throw new Exception( pht( 'This command implementation("%s") can not apply a command of a '. 'different type ("%s").', $implementation_key, $command_key)); } if (!$this->canApplyToItem($item)) { throw new Exception( pht( 'This command implementation ("%s") can not be applied to an '. 'item of type "%s".', $implementation_key, $item->getItemType())); } $this->transactionQueue = array(); $command_type = NuanceItemCommandTransaction::TRANSACTIONTYPE; $command_xaction = $this->newTransaction($command_type); $result = $this->executeCommand($item, $command); $xactions = $this->transactionQueue; $this->transactionQueue = array(); $command_xaction->setNewValue( array( 'command' => $command->getCommand(), 'parameters' => $command->getParameters(), 'result' => $result, )); // TODO: Maybe preserve the actor's original content source? $source = PhabricatorContentSource::newForSource( PhabricatorDaemonContentSource::SOURCECONST); $actor = $this->getActor(); id(new NuanceItemEditor()) ->setActor($actor) ->setActingAsPHID($command->getAuthorPHID()) ->setContentSource($source) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true) ->applyTransactions($item, $xactions); } final public function getCommandKey() { return $this->getPhobjectClassConstant('COMMANDKEY'); } final public static function getAllCommands() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getCommandKey') ->execute(); } protected function newTransaction($type) { $xaction = id(new NuanceItemTransaction()) ->setTransactionType($type); $this->transactionQueue[] = $xaction; return $xaction; } protected function newStatusTransaction($status) { return $this->newTransaction(NuanceItemStatusTransaction::TRANSACTIONTYPE) ->setNewValue($status); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/command/NuanceItemCommandSpec.php
src/applications/nuance/command/NuanceItemCommandSpec.php
<?php final class NuanceItemCommandSpec extends Phobject { private $commandKey; private $name; private $icon; public function setCommandKey($command_key) { $this->commandKey = $command_key; return $this; } public function getCommandKey() { return $this->commandKey; } public function setName($name) { $this->name = $name; return $this; } public function getName() { return $this->name; } public function setIcon($icon) { $this->icon = $icon; return $this; } public function getIcon() { return $this->icon; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/cursor/NuanceGitHubIssuesImportCursor.php
src/applications/nuance/cursor/NuanceGitHubIssuesImportCursor.php
<?php final class NuanceGitHubIssuesImportCursor extends NuanceGitHubImportCursor { const CURSORTYPE = 'github.issues'; protected function getGitHubAPIEndpointURI($user, $repository) { return "/repos/{$user}/{$repository}/issues/events"; } protected function newNuanceItemFromGitHubRecord(array $record) { $source = $this->getSource(); $id = $record['id']; $item_key = "github.issueevent.{$id}"; $container_key = null; return NuanceItem::initializeNewItem(NuanceGitHubEventItemType::ITEMTYPE) ->setStatus(NuanceItem::STATUS_IMPORTING) ->setSourcePHID($source->getPHID()) ->setItemKey($item_key) ->setItemContainerKey($container_key) ->setItemProperty('api.type', 'issue') ->setItemProperty('api.raw', $record); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/cursor/NuanceImportCursor.php
src/applications/nuance/cursor/NuanceImportCursor.php
<?php abstract class NuanceImportCursor extends Phobject { private $cursorData; private $cursorKey; private $source; private $viewer; abstract protected function shouldPullDataFromSource(); abstract protected function pullDataFromSource(); final public function getCursorType() { return $this->getPhobjectClassConstant('CURSORTYPE', 32); } public function setCursorData(NuanceImportCursorData $cursor_data) { $this->cursorData = $cursor_data; return $this; } public function getCursorData() { return $this->cursorData; } public function setSource($source) { $this->source = $source; return $this; } public function getSource() { return $this->source; } public function setCursorKey($cursor_key) { $this->cursorKey = $cursor_key; return $this; } public function getCursorKey() { return $this->cursorKey; } public function setViewer($viewer) { $this->viewer = $viewer; return $this; } public function getViewer() { return $this->viewer; } final public function importFromSource() { if (!$this->shouldPullDataFromSource()) { return false; } $source = $this->getSource(); $key = $this->getCursorKey(); $parts = array( 'nsc', $source->getID(), PhabricatorHash::digestToLength($key, 20), ); $lock_name = implode('.', $parts); $lock = PhabricatorGlobalLock::newLock($lock_name); $lock->lock(1); try { $more_data = $this->pullDataFromSource(); } catch (Exception $ex) { $lock->unlock(); throw $ex; } $lock->unlock(); return $more_data; } final public function newEmptyCursorData(NuanceSource $source) { return id(new NuanceImportCursorData()) ->setCursorKey($this->getCursorKey()) ->setCursorType($this->getCursorType()) ->setSourcePHID($source->getPHID()); } final protected function logInfo($message) { echo tsprintf( "<cursor:%s> %s\n", $this->getCursorKey(), $message); return $this; } final protected function getCursorProperty($key, $default = null) { return $this->getCursorData()->getCursorProperty($key, $default); } final protected function setCursorProperty($key, $value) { $this->getCursorData()->setCursorProperty($key, $value); return $this; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/cursor/NuanceGitHubRepositoryImportCursor.php
src/applications/nuance/cursor/NuanceGitHubRepositoryImportCursor.php
<?php final class NuanceGitHubRepositoryImportCursor extends NuanceGitHubImportCursor { const CURSORTYPE = 'github.repository'; protected function getGitHubAPIEndpointURI($user, $repository) { return "/repos/{$user}/{$repository}/events"; } protected function getMaximumPage() { return 10; } protected function getPageSize() { return 30; } protected function newNuanceItemFromGitHubRecord(array $record) { $source = $this->getSource(); $id = $record['id']; $item_key = "github.event.{$id}"; $container_key = null; $issue_id = idxv( $record, array( 'payload', 'issue', 'id', )); if ($issue_id) { $container_key = "github.issue.{$issue_id}"; } return NuanceItem::initializeNewItem(NuanceGitHubEventItemType::ITEMTYPE) ->setStatus(NuanceItem::STATUS_IMPORTING) ->setSourcePHID($source->getPHID()) ->setItemKey($item_key) ->setItemContainerKey($container_key) ->setItemProperty('api.type', 'repository') ->setItemProperty('api.raw', $record); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/cursor/NuanceGitHubImportCursor.php
src/applications/nuance/cursor/NuanceGitHubImportCursor.php
<?php abstract class NuanceGitHubImportCursor extends NuanceImportCursor { abstract protected function getGitHubAPIEndpointURI($user, $repository); abstract protected function newNuanceItemFromGitHubRecord(array $record); protected function getMaximumPage() { return 100; } protected function getPageSize() { return 100; } protected function getMinimumDelayBetweenPolls() { // Even if GitHub says we can, don't poll more than once every few seconds. // In particular, the Issue Events API does not advertise a poll interval // in a header. return 5; } final protected function shouldPullDataFromSource() { $now = PhabricatorTime::getNow(); // Respect GitHub's poll interval header. If we made a request recently, // don't make another one until we've waited long enough. $ttl = $this->getCursorProperty('github.poll.ttl'); if ($ttl && ($ttl >= $now)) { $this->logInfo( pht( 'Respecting "%s" or minimum poll delay: waiting for %s second(s) '. 'to poll GitHub.', 'X-Poll-Interval', new PhutilNumber(1 + ($ttl - $now)))); return false; } // Respect GitHub's API rate limiting. If we've exceeded the rate limit, // wait until it resets to try again. $limit = $this->getCursorProperty('github.limit.ttl'); if ($limit && ($limit >= $now)) { $this->logInfo( pht( 'Respecting "%s": waiting for %s second(s) to poll GitHub.', 'X-RateLimit-Reset', new PhutilNumber(1 + ($limit - $now)))); return false; } return true; } final protected function pullDataFromSource() { $viewer = $this->getViewer(); $now = PhabricatorTime::getNow(); $source = $this->getSource(); $user = $source->getSourceProperty('github.user'); $repository = $source->getSourceProperty('github.repository'); $api_token = $source->getSourceProperty('github.token'); // This API only supports fetching 10 pages of 30 events each, for a total // of 300 events. $etag = null; $new_items = array(); $hit_known_items = false; $max_page = $this->getMaximumPage(); $page_size = $this->getPageSize(); for ($page = 1; $page <= $max_page; $page++) { $uri = $this->getGitHubAPIEndpointURI($user, $repository); $data = array( 'page' => $page, 'per_page' => $page_size, ); $future = id(new PhutilGitHubFuture()) ->setAccessToken($api_token) ->setRawGitHubQuery($uri, $data); if ($page == 1) { $cursor_etag = $this->getCursorProperty('github.poll.etag'); if ($cursor_etag) { $future->addHeader('If-None-Match', $cursor_etag); } } $this->logInfo( pht( 'Polling GitHub Repository API endpoint "%s".', $uri)); $response = $future->resolve(); // Do this first: if we hit the rate limit, we get a response but the // body isn't valid. $this->updateRateLimits($response); if ($response->getStatus()->getStatusCode() == 304) { $this->logInfo( pht( 'Received a 304 Not Modified from GitHub, no new events.')); } // This means we hit a rate limit or a "Not Modified" because of the // "ETag" header. In either case, we should bail out. if ($response->getStatus()->isError()) { $this->updatePolling($response, $now, false); $this->getCursorData()->save(); return false; } if ($page == 1) { $etag = $response->getHeaderValue('ETag'); } $records = $response->getBody(); foreach ($records as $record) { $item = $this->newNuanceItemFromGitHubRecord($record); $item_key = $item->getItemKey(); $this->logInfo( pht( 'Fetched event "%s".', $item_key)); $new_items[$item->getItemKey()] = $item; } if ($new_items) { $existing = id(new NuanceItemQuery()) ->setViewer($viewer) ->withSourcePHIDs(array($source->getPHID())) ->withItemKeys(array_keys($new_items)) ->execute(); $existing = mpull($existing, null, 'getItemKey'); foreach ($new_items as $key => $new_item) { if (isset($existing[$key])) { unset($new_items[$key]); $hit_known_items = true; $this->logInfo( pht( 'Event "%s" is previously known.', $key)); } } } if ($hit_known_items) { break; } if (count($records) < $page_size) { break; } } // TODO: When we go through the whole queue without hitting anything we // have seen before, we should record some sort of global event so we // can tell the user when the bridging started or was interrupted? if (!$hit_known_items) { $already_polled = $this->getCursorProperty('github.polled'); if ($already_polled) { // TODO: This is bad: we missed some items, maybe because too much // stuff happened too fast or the daemons were broken for a long // time. } else { // TODO: This is OK, we're doing the initial import. } } if ($etag !== null) { $this->updateETag($etag); } $this->updatePolling($response, $now, true); // Reverse the new items so we insert them in chronological order. $new_items = array_reverse($new_items); $source->openTransaction(); foreach ($new_items as $new_item) { $new_item->save(); } $this->getCursorData()->save(); $source->saveTransaction(); foreach ($new_items as $new_item) { $new_item->scheduleUpdate(); } return false; } private function updateRateLimits(PhutilGitHubResponse $response) { $remaining = $response->getHeaderValue('X-RateLimit-Remaining'); $limit_reset = $response->getHeaderValue('X-RateLimit-Reset'); $now = PhabricatorTime::getNow(); $limit_ttl = null; if (strlen($remaining)) { $remaining = (int)$remaining; if (!$remaining) { $limit_ttl = (int)$limit_reset; } } $this->setCursorProperty('github.limit.ttl', $limit_ttl); $this->logInfo( pht( 'This key has %s remaining API request(s), '. 'limit resets in %s second(s).', new PhutilNumber($remaining), new PhutilNumber($limit_reset - $now))); } private function updateETag($etag) { $this->setCursorProperty('github.poll.etag', $etag); $this->logInfo( pht( 'ETag for this request was "%s".', $etag)); } private function updatePolling( PhutilGitHubResponse $response, $start, $success) { if ($success) { $this->setCursorProperty('github.polled', true); } $poll_interval = (int)$response->getHeaderValue('X-Poll-Interval'); $poll_interval = max($this->getMinimumDelayBetweenPolls(), $poll_interval); $poll_ttl = $start + $poll_interval; $this->setCursorProperty('github.poll.ttl', $poll_ttl); $now = PhabricatorTime::getNow(); $this->logInfo( pht( 'Set API poll TTL to +%s second(s) (%s second(s) from now).', new PhutilNumber($poll_interval), new PhutilNumber($poll_ttl - $now))); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/editor/NuanceQueueEditEngine.php
src/applications/nuance/editor/NuanceQueueEditEngine.php
<?php final class NuanceQueueEditEngine extends PhabricatorEditEngine { const ENGINECONST = 'nuance.queue'; public function isEngineConfigurable() { return false; } public function getEngineName() { return pht('Nuance Queues'); } public function getSummaryHeader() { return pht('Edit Nuance Queue Configurations'); } public function getSummaryText() { return pht('This engine is used to edit Nuance queues.'); } public function getEngineApplicationClass() { return 'PhabricatorNuanceApplication'; } protected function newEditableObject() { return NuanceQueue::initializeNewQueue(); } protected function newObjectQuery() { return new NuanceQueueQuery(); } protected function getObjectCreateTitleText($object) { return pht('Create Queue'); } protected function getObjectCreateButtonText($object) { return pht('Create Queue'); } protected function getObjectEditTitleText($object) { return pht('Edit Queue: %s', $object->getName()); } protected function getObjectEditShortText($object) { return pht('Edit Queue'); } protected function getObjectCreateShortText() { return pht('Create Queue'); } protected function getObjectName() { return pht('Queue'); } protected function getEditorURI() { return '/nuance/queue/edit/'; } protected function getObjectCreateCancelURI($object) { return '/nuance/queue/'; } protected function getObjectViewURI($object) { return $object->getURI(); } protected function buildCustomEditFields($object) { return array( id(new PhabricatorTextEditField()) ->setKey('name') ->setLabel(pht('Name')) ->setDescription(pht('Name of the queue.')) ->setTransactionType(NuanceQueueNameTransaction::TRANSACTIONTYPE) ->setIsRequired(true) ->setValue($object->getName()), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/editor/NuanceSourceEditor.php
src/applications/nuance/editor/NuanceSourceEditor.php
<?php final class NuanceSourceEditor extends PhabricatorApplicationTransactionEditor { public function getEditorApplicationClass() { return 'PhabricatorNuanceApplication'; } public function getEditorObjectsDescription() { return pht('Nuance Sources'); } protected function supportsSearch() { return true; } public function getTransactionTypes() { $types = parent::getTransactionTypes(); $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; return $types; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/editor/NuanceSourceEditEngine.php
src/applications/nuance/editor/NuanceSourceEditEngine.php
<?php final class NuanceSourceEditEngine extends PhabricatorEditEngine { const ENGINECONST = 'nuance.source'; private $sourceDefinition; public function setSourceDefinition( NuanceSourceDefinition $source_definition) { $this->sourceDefinition = $source_definition; return $this; } public function getSourceDefinition() { return $this->sourceDefinition; } public function isEngineConfigurable() { return false; } public function getEngineName() { return pht('Nuance Sources'); } public function getSummaryHeader() { return pht('Edit Nuance Source Configurations'); } public function getSummaryText() { return pht('This engine is used to edit Nuance sources.'); } public function getEngineApplicationClass() { return 'PhabricatorNuanceApplication'; } protected function newEditableObject() { $viewer = $this->getViewer(); $definition = $this->getSourceDefinition(); if (!$definition) { throw new PhutilInvalidStateException('setSourceDefinition'); } return NuanceSource::initializeNewSource( $viewer, $definition); } protected function newObjectQuery() { return new NuanceSourceQuery(); } protected function getObjectCreateTitleText($object) { return pht('Create Source'); } protected function getObjectCreateButtonText($object) { return pht('Create Source'); } protected function getObjectEditTitleText($object) { return pht('Edit Source: %s', $object->getName()); } protected function getObjectEditShortText($object) { return pht('Edit Source'); } protected function getObjectCreateShortText() { return pht('Create Source'); } protected function getObjectName() { return pht('Source'); } protected function getEditorURI() { return '/nuance/source/edit/'; } protected function getObjectCreateCancelURI($object) { return '/nuance/source/'; } protected function getObjectViewURI($object) { return $object->getURI(); } protected function buildCustomEditFields($object) { return array( id(new PhabricatorTextEditField()) ->setKey('name') ->setLabel(pht('Name')) ->setDescription(pht('Name of the source.')) ->setTransactionType(NuanceSourceNameTransaction::TRANSACTIONTYPE) ->setIsRequired(true) ->setValue($object->getName()), id(new PhabricatorDatasourceEditField()) ->setKey('defaultQueue') ->setLabel(pht('Default Queue')) ->setDescription(pht('Default queue.')) ->setTransactionType( NuanceSourceDefaultQueueTransaction::TRANSACTIONTYPE) ->setDatasource(new NuanceQueueDatasource()) ->setSingleValue($object->getDefaultQueuePHID()), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/editor/NuanceQueueEditor.php
src/applications/nuance/editor/NuanceQueueEditor.php
<?php final class NuanceQueueEditor extends PhabricatorApplicationTransactionEditor { public function getEditorApplicationClass() { return 'PhabricatorNuanceApplication'; } public function getEditorObjectsDescription() { return pht('Nuance Queues'); } public function getTransactionTypes() { $types = parent::getTransactionTypes(); $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; return $types; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/editor/NuanceItemEditor.php
src/applications/nuance/editor/NuanceItemEditor.php
<?php final class NuanceItemEditor extends PhabricatorApplicationTransactionEditor { public function getEditorApplicationClass() { return 'PhabricatorNuanceApplication'; } public function getEditorObjectsDescription() { return pht('Nuance Items'); } public function getTransactionTypes() { $types = parent::getTransactionTypes(); $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; return $types; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/xaction/NuanceItemPropertyTransaction.php
src/applications/nuance/xaction/NuanceItemPropertyTransaction.php
<?php final class NuanceItemPropertyTransaction extends NuanceItemTransactionType { const TRANSACTIONTYPE = 'nuance.item.property'; public function generateOldValue($object) { $property_key = NuanceItemTransaction::PROPERTY_KEY; $key = $this->getMetadataValue($property_key); return $object->getItemProperty($key); } public function applyInternalEffects($object, $value) { $property_key = NuanceItemTransaction::PROPERTY_KEY; $key = $this->getMetadataValue($property_key); $object->setItemProperty($key, $value); } public function getTitle() { return pht( '%s set a property on this item.', $this->renderAuthor()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/xaction/NuanceItemTransactionType.php
src/applications/nuance/xaction/NuanceItemTransactionType.php
<?php abstract class NuanceItemTransactionType 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/nuance/xaction/NuanceSourceDefaultQueueTransaction.php
src/applications/nuance/xaction/NuanceSourceDefaultQueueTransaction.php
<?php final class NuanceSourceDefaultQueueTransaction extends NuanceSourceTransactionType { const TRANSACTIONTYPE = 'source.queue.default'; public function generateOldValue($object) { return $object->getDefaultQueuePHID(); } public function applyInternalEffects($object, $value) { $object->setDefaultQueuePHID($value); } public function getTitle() { return pht( '%s changed the default queue for this source from %s to %s.', $this->renderAuthor(), $this->renderOldHandle(), $this->renderNewHandle()); } public function validateTransactions($object, array $xactions) { $errors = array(); if (!$object->getDefaultQueuePHID() && !$xactions) { $errors[] = $this->newRequiredError( pht('Sources must have a default queue.')); } foreach ($xactions as $xaction) { if (!$xaction->getNewValue()) { $errors[] = $this->newRequiredError( pht('Sources must have a default queue.')); } } 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/nuance/xaction/NuanceItemRequestorTransaction.php
src/applications/nuance/xaction/NuanceItemRequestorTransaction.php
<?php final class NuanceItemRequestorTransaction extends NuanceItemTransactionType { const TRANSACTIONTYPE = 'nuance.item.requestor'; public function generateOldValue($object) { return $object->getRequestorPHID(); } public function applyInternalEffects($object, $value) { $object->setRequestorPHID($value); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/xaction/NuanceQueueNameTransaction.php
src/applications/nuance/xaction/NuanceQueueNameTransaction.php
<?php final class NuanceQueueNameTransaction extends NuanceQueueTransactionType { const TRANSACTIONTYPE = 'nuance.queue.name'; public function generateOldValue($object) { return $object->getName(); } public function applyInternalEffects($object, $value) { $object->setName($value); } public function getTitle() { return pht( '%s renamed this queue from %s to %s.', $this->renderAuthor(), $this->renderOldValue(), $this->renderNewValue()); } public function validateTransactions($object, array $xactions) { $errors = array(); if ($this->isEmptyTextTransaction($object->getName(), $xactions)) { $errors[] = $this->newRequiredError( pht('Queues 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( 'Queue names must not be longer than %s character(s).', new PhutilNumber($max_length))); } } 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/nuance/xaction/NuanceItemCommandTransaction.php
src/applications/nuance/xaction/NuanceItemCommandTransaction.php
<?php final class NuanceItemCommandTransaction extends NuanceItemTransactionType { const TRANSACTIONTYPE = 'nuance.item.command'; public function generateOldValue($object) { return null; } public function getTitle() { $spec = $this->getNewValue(); $command_key = idx($spec, 'command', '???'); return pht( '%s applied a "%s" command to this item.', $this->renderAuthor(), $command_key); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/xaction/NuanceQueueTransactionType.php
src/applications/nuance/xaction/NuanceQueueTransactionType.php
<?php abstract class NuanceQueueTransactionType 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/nuance/xaction/NuanceItemStatusTransaction.php
src/applications/nuance/xaction/NuanceItemStatusTransaction.php
<?php final class NuanceItemStatusTransaction extends NuanceItemTransactionType { const TRANSACTIONTYPE = 'nuance.item.status'; public function generateOldValue($object) { return $object->getStatus(); } public function applyInternalEffects($object, $value) { $object->setStatus($value); } public function getTitle() { return pht( '%s changed the status of this item from %s to %s.', $this->renderAuthor(), $this->renderOldValue(), $this->renderNewValue()); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/xaction/NuanceItemOwnerTransaction.php
src/applications/nuance/xaction/NuanceItemOwnerTransaction.php
<?php final class NuanceItemOwnerTransaction extends NuanceItemTransactionType { const TRANSACTIONTYPE = 'nuance.item.owner'; public function generateOldValue($object) { return $object->getOwnerPHID(); } public function applyInternalEffects($object, $value) { $object->setOwnerPHID($value); } public function getTitle() { // TODO: Assign, unassign strings probably need variants. return pht( '%s reassigned this item from %s to %s.', $this->renderAuthor(), $this->renderHandle($this->getOldValue()), $this->renderHandle($this->getNewValue())); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/xaction/NuanceSourceTransactionType.php
src/applications/nuance/xaction/NuanceSourceTransactionType.php
<?php abstract class NuanceSourceTransactionType 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/nuance/xaction/NuanceItemQueueTransaction.php
src/applications/nuance/xaction/NuanceItemQueueTransaction.php
<?php final class NuanceItemQueueTransaction extends NuanceItemTransactionType { const TRANSACTIONTYPE = 'nuance.item.queue'; public function generateOldValue($object) { return $object->getQueuePHID(); } public function applyInternalEffects($object, $value) { $object->setQueuePHID($value); } public function getTitle() { return pht( '%s rerouted this item from %s to %s.', $this->renderAuthor(), $this->renderHandle($this->getOldValue()), $this->renderHandle($this->getNewValue())); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/xaction/NuanceItemSourceTransaction.php
src/applications/nuance/xaction/NuanceItemSourceTransaction.php
<?php final class NuanceItemSourceTransaction extends NuanceItemTransactionType { const TRANSACTIONTYPE = 'nuance.item.source'; public function generateOldValue($object) { return $object->getSourcePHID(); } public function applyInternalEffects($object, $value) { $object->setSourcePHID($value); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/xaction/NuanceSourceNameTransaction.php
src/applications/nuance/xaction/NuanceSourceNameTransaction.php
<?php final class NuanceSourceNameTransaction extends NuanceSourceTransactionType { const TRANSACTIONTYPE = 'source.name'; public function generateOldValue($object) { return $object->getName(); } public function applyInternalEffects($object, $value) { $object->setName($value); } public function getTitle() { return pht( '%s renamed this source from %s to %s.', $this->renderAuthor(), $this->renderOldValue(), $this->renderNewValue()); } public function validateTransactions($object, array $xactions) { $errors = array(); if ($this->isEmptyTextTransaction($object->getName(), $xactions)) { $errors[] = $this->newRequiredError( pht('Sources 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( 'Source names must not be longer than %s character(s).', new PhutilNumber($max_length))); } } 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/nuance/github/NuanceGitHubRawEvent.php
src/applications/nuance/github/NuanceGitHubRawEvent.php
<?php final class NuanceGitHubRawEvent extends Phobject { private $raw; private $type; const TYPE_ISSUE = 'issue'; const TYPE_REPOSITORY = 'repository'; public static function newEvent($type, array $raw) { $event = new self(); $event->type = $type; $event->raw = $raw; return $event; } public function getRepositoryFullName() { return $this->getRepositoryFullRawName(); } public function isIssueEvent() { if ($this->isPullRequestEvent()) { return false; } if ($this->type == self::TYPE_ISSUE) { return true; } switch ($this->getIssueRawKind()) { case 'IssuesEvent': return true; case 'IssueCommentEvent': if (!$this->getRawPullRequestData()) { return true; } break; } return false; } public function isPullRequestEvent() { if ($this->type == self::TYPE_ISSUE) { // TODO: This is wrong, some of these are pull events. return false; } $raw = $this->raw; switch ($this->getIssueRawKind()) { case 'PullRequestEvent': return true; case 'IssueCommentEvent': if ($this->getRawPullRequestData()) { return true; } break; } return false; } public function getIssueNumber() { if (!$this->isIssueEvent()) { return null; } return $this->getRawIssueNumber(); } public function getPullRequestNumber() { if (!$this->isPullRequestEvent()) { return null; } return $this->getRawIssueNumber(); } public function getID() { $raw = $this->raw; $id = idx($raw, 'id'); if ($id) { return (int)$id; } return null; } public function getComment() { if (!$this->isIssueEvent() && !$this->isPullRequestEvent()) { return null; } $raw = $this->raw; return idxv($raw, array('payload', 'comment', 'body')); } public function getURI() { $raw = $this->raw; if ($this->isIssueEvent() || $this->isPullRequestEvent()) { if ($this->type == self::TYPE_ISSUE) { $uri = idxv($raw, array('issue', 'html_url')); $uri = $uri.'#event-'.$this->getID(); } else { // The format of pull request events varies so we need to fish around // a bit to find the correct URI. $uri = idxv($raw, array('payload', 'pull_request', 'html_url')); $need_anchor = true; // For comments, we get a different anchor to link to the comment. In // this case, the URI comes with an anchor already. if (!$uri) { $uri = idxv($raw, array('payload', 'comment', 'html_url')); $need_anchor = false; } if (!$uri) { $uri = idxv($raw, array('payload', 'issue', 'html_url')); $need_anchor = true; } if ($need_anchor) { $uri = $uri.'#event-'.$this->getID(); } } } else { switch ($this->getIssueRawKind()) { case 'CreateEvent': $ref = idxv($raw, array('payload', 'ref')); $repo = $this->getRepositoryFullRawName(); return "https://github.com/{$repo}/commits/{$ref}"; case 'PushEvent': // These don't really have a URI since there may be multiple commits // involved and GitHub doesn't bundle the push as an object on its // own. Just try to find the URI for the log. The API also does // not return any HTML URI for these events. $head = idxv($raw, array('payload', 'head')); if ($head === null) { return null; } $repo = $this->getRepositoryFullRawName(); return "https://github.com/{$repo}/commits/{$head}"; case 'WatchEvent': // These have no reasonable URI. return null; default: return null; } } return $uri; } private function getRepositoryFullRawName() { $raw = $this->raw; $full = idxv($raw, array('repo', 'name')); if (phutil_nonempty_string($full)) { return $full; } // For issue events, the repository is not identified explicitly in the // response body. Parse it out of the URI. $matches = null; $ok = preg_match( '(/repos/((?:[^/]+)/(?:[^/]+))/issues/events/)', idx($raw, 'url'), $matches); if ($ok) { return $matches[1]; } return null; } private function getIssueRawKind() { $raw = $this->raw; return idxv($raw, array('type')); } private function getRawIssueNumber() { $raw = $this->raw; if ($this->type == self::TYPE_ISSUE) { return idxv($raw, array('issue', 'number')); } if ($this->type == self::TYPE_REPOSITORY) { $issue_number = idxv($raw, array('payload', 'issue', 'number')); if ($issue_number) { return $issue_number; } $pull_number = idxv($raw, array('payload', 'number')); if ($pull_number) { return $pull_number; } } return null; } private function getRawPullRequestData() { $raw = $this->raw; return idxv($raw, array('payload', 'issue', 'pull_request')); } public function getEventFullTitle() { switch ($this->type) { case self::TYPE_ISSUE: $title = $this->getRawIssueEventTitle(); break; case self::TYPE_REPOSITORY: $title = $this->getRawRepositoryEventTitle(); break; default: $title = pht('Unknown Event Type ("%s")', $this->type); break; } return pht( 'GitHub %s %s (%s)', $this->getRepositoryFullRawName(), $this->getTargetObjectName(), $title); } public function getActorGitHubUserID() { $raw = $this->raw; return (int)idxv($raw, array('actor', 'id')); } private function getTargetObjectName() { if ($this->isPullRequestEvent()) { $number = $this->getRawIssueNumber(); return pht('Pull Request #%d', $number); } else if ($this->isIssueEvent()) { $number = $this->getRawIssueNumber(); return pht('Issue #%d', $number); } else if ($this->type == self::TYPE_REPOSITORY) { $raw = $this->raw; $type = idx($raw, 'type'); switch ($type) { case 'CreateEvent': $ref = idxv($raw, array('payload', 'ref')); $ref_type = idxv($raw, array('payload', 'ref_type')); switch ($ref_type) { case 'branch': return pht('Branch %s', $ref); case 'tag': return pht('Tag %s', $ref); default: return pht('Ref %s', $ref); } break; case 'PushEvent': $ref = idxv($raw, array('payload', 'ref')); if (preg_match('(^refs/heads/)', $ref)) { return pht('Branch %s', substr($ref, strlen('refs/heads/'))); } else { return pht('Ref %s', $ref); } break; case 'WatchEvent': $actor = idxv($raw, array('actor', 'login')); return pht('User %s', $actor); } return pht('Unknown Object'); } else { return pht('Unknown Object'); } } private function getRawIssueEventTitle() { $raw = $this->raw; $action = idxv($raw, array('event')); switch ($action) { case 'assigned': $assignee = idxv($raw, array('assignee', 'login')); $title = pht('Assigned: %s', $assignee); break; case 'closed': $title = pht('Closed'); break; case 'demilestoned': $milestone = idxv($raw, array('milestone', 'title')); $title = pht('Removed Milestone: %s', $milestone); break; case 'labeled': $label = idxv($raw, array('label', 'name')); $title = pht('Added Label: %s', $label); break; case 'locked': $title = pht('Locked'); break; case 'milestoned': $milestone = idxv($raw, array('milestone', 'title')); $title = pht('Added Milestone: %s', $milestone); break; case 'renamed': $title = pht('Renamed'); break; case 'reopened': $title = pht('Reopened'); break; case 'unassigned': $assignee = idxv($raw, array('assignee', 'login')); $title = pht('Unassigned: %s', $assignee); break; case 'unlabeled': $label = idxv($raw, array('label', 'name')); $title = pht('Removed Label: %s', $label); break; case 'unlocked': $title = pht('Unlocked'); break; default: $title = pht('"%s"', $action); break; } return $title; } private function getRawRepositoryEventTitle() { $raw = $this->raw; $type = idx($raw, 'type'); switch ($type) { case 'CreateEvent': return pht('Created'); case 'PushEvent': $head = idxv($raw, array('payload', 'head')); $head = substr($head, 0, 12); return pht('Pushed: %s', $head); case 'IssuesEvent': $action = idxv($raw, array('payload', 'action')); switch ($action) { case 'closed': return pht('Closed'); case 'opened': return pht('Created'); case 'reopened': return pht('Reopened'); default: return pht('"%s"', $action); } break; case 'IssueCommentEvent': $action = idxv($raw, array('payload', 'action')); switch ($action) { case 'created': return pht('Comment'); default: return pht('"%s"', $action); } break; case 'PullRequestEvent': $action = idxv($raw, array('payload', 'action')); switch ($action) { case 'opened': return pht('Created'); default: return pht('"%s"', $action); } break; case 'WatchEvent': return pht('Watched'); } return pht('"%s"', $type); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/github/__tests__/NuanceGitHubRawEventTestCase.php
src/applications/nuance/github/__tests__/NuanceGitHubRawEventTestCase.php
<?php final class NuanceGitHubRawEventTestCase extends PhabricatorTestCase { public function testIssueEvents() { $path = dirname(__FILE__).'/issueevents/'; $cases = $this->readTestCases($path); foreach ($cases as $name => $info) { $input = $info['input']; $expect = $info['expect']; $event = NuanceGitHubRawEvent::newEvent( NuanceGitHubRawEvent::TYPE_ISSUE, $input); $this->assertGitHubRawEventParse($expect, $event, $name); } } public function testRepositoryEvents() { $path = dirname(__FILE__).'/repositoryevents/'; $cases = $this->readTestCases($path); foreach ($cases as $name => $info) { $input = $info['input']; $expect = $info['expect']; $event = NuanceGitHubRawEvent::newEvent( NuanceGitHubRawEvent::TYPE_REPOSITORY, $input); $this->assertGitHubRawEventParse($expect, $event, $name); } } private function assertGitHubRawEventParse( array $expect, NuanceGitHubRawEvent $event, $name) { $actual = array( 'repository.name.full' => $event->getRepositoryFullName(), 'is.issue' => $event->isIssueEvent(), 'is.pull' => $event->isPullRequestEvent(), 'issue.number' => $event->getIssueNumber(), 'pull.number' => $event->getPullRequestNumber(), 'id' => $event->getID(), 'uri' => $event->getURI(), 'title.full' => $event->getEventFullTitle(), 'comment' => $event->getComment(), 'actor.id' => $event->getActorGitHubUserID(), ); // Only verify the keys which are actually present in the test. This // allows tests to specify only relevant keys. $actual = array_select_keys($actual, array_keys($expect)); ksort($expect); ksort($actual); $this->assertEqual($expect, $actual, $name); } private function readTestCases($path) { $files = Filesystem::listDirectory($path, $include_hidden = false); $tests = array(); foreach ($files as $file) { $data = Filesystem::readFile($path.$file); $parts = preg_split('/^~{5,}$/m', $data); if (count($parts) < 2) { throw new Exception( pht( 'Expected test file "%s" to contain an input section in JSON, '. 'then an expected result section in JSON, with the two sections '. 'separated by a line of "~~~~~", but the divider is not present '. 'in the file.', $file)); } else if (count($parts) > 2) { throw new Exception( pht( 'Expected test file "%s" to contain exactly two sections, '. 'but it has more than two sections.', $file)); } list($input, $expect) = $parts; try { $input = phutil_json_decode($input); $expect = phutil_json_decode($expect); } catch (Exception $ex) { throw new PhutilProxyException( pht( 'Exception while decoding test data for test "%s".', $file), $ex); } $tests[$file] = array( 'input' => $input, 'expect' => $expect, ); } return $tests; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/source/NuanceSourceDefinition.php
src/applications/nuance/source/NuanceSourceDefinition.php
<?php /** * @task action Handling Action Requests */ abstract class NuanceSourceDefinition extends Phobject { private $viewer; private $source; public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } public function getViewer() { if (!$this->viewer) { throw new PhutilInvalidStateException('setViewer'); } return $this->viewer; } public function setSource(NuanceSource $source) { $this->source = $source; return $this; } public function getSource() { if (!$this->source) { throw new PhutilInvalidStateException('setSource'); } return $this->source; } public function getSourceViewActions(AphrontRequest $request) { return array(); } public static function getAllDefinitions() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getSourceTypeConstant') ->execute(); } public function hasImportCursors() { return false; } final public function getImportCursors() { if (!$this->hasImportCursors()) { throw new Exception( pht('This source has no input cursors.')); } $viewer = PhabricatorUser::getOmnipotentUser(); $source = $this->getSource(); $cursors = $this->newImportCursors(); $data = id(new NuanceImportCursorDataQuery()) ->setViewer($viewer) ->withSourcePHIDs(array($source->getPHID())) ->execute(); $data = mpull($data, null, 'getCursorKey'); $map = array(); foreach ($cursors as $cursor) { if (!($cursor instanceof NuanceImportCursor)) { throw new Exception( pht( 'Source "%s" (of class "%s") returned an invalid value from '. 'method "%s": all values must be objects of class "%s".', $this->getName(), get_class($this), 'newImportCursors()', 'NuanceImportCursor')); } $key = $cursor->getCursorKey(); if (!strlen($key)) { throw new Exception( pht( 'Source "%s" (of class "%s") returned an import cursor with '. 'a missing key from "%s". Each cursor must have a unique, '. 'nonempty key.', $this->getName(), get_class($this), 'newImportCursors()')); } $other = idx($map, $key); if ($other) { throw new Exception( pht( 'Source "%s" (of class "%s") returned two cursors from method '. '"%s" with the same key ("%s"). Each cursor must have a unique '. 'key.', $this->getName(), get_class($this), 'newImportCursors()', $key)); } $map[$key] = $cursor; $cursor_data = idx($data, $key); if (!$cursor_data) { $cursor_data = $cursor->newEmptyCursorData($source); } $cursor ->setViewer($viewer) ->setSource($source) ->setCursorData($cursor_data); } return $map; } protected function newImportCursors() { throw new PhutilMethodNotImplementedException(); } /** * A human readable string like "Twitter" or "Phabricator Form". */ abstract public function getName(); /** * Human readable description of this source, a sentence or two long. */ abstract public function getSourceDescription(); /** * This should be a any VARCHAR(32). * * @{method:getAllDefinitions} will throw if you choose a string that * collides with another @{class:NuanceSourceDefinition} class. */ abstract public function getSourceTypeConstant(); public function renderView() { return null; } public function renderListView() { return null; } protected function newItemFromProperties( $item_type, $author_phid, array $properties, PhabricatorContentSource $content_source) { // TODO: Should we have a tighter actor/viewer model? Requestors will // often have no real user associated with them... $actor = PhabricatorUser::getOmnipotentUser(); $source = $this->getSource(); $item = NuanceItem::initializeNewItem($item_type); $xactions = array(); $xactions[] = id(new NuanceItemTransaction()) ->setTransactionType(NuanceItemSourceTransaction::TRANSACTIONTYPE) ->setNewValue($source->getPHID()); // TODO: Eventually, apply real routing rules. For now, just put everything // in the default queue for the source. $xactions[] = id(new NuanceItemTransaction()) ->setTransactionType(NuanceItemQueueTransaction::TRANSACTIONTYPE) ->setNewValue($source->getDefaultQueuePHID()); // TODO: Maybe this should all be modular transactions now? foreach ($properties as $key => $property) { $xactions[] = id(new NuanceItemTransaction()) ->setTransactionType(NuanceItemPropertyTransaction::TRANSACTIONTYPE) ->setMetadataValue(NuanceItemTransaction::PROPERTY_KEY, $key) ->setNewValue($property); } $editor = id(new NuanceItemEditor()) ->setActor($actor) ->setActingAsPHID($author_phid) ->setContentSource($content_source); $editor->applyTransactions($item, $xactions); return $item; } public function renderItemEditProperties( PhabricatorUser $viewer, NuanceItem $item, PHUIPropertyListView $view) { return; } /* -( Handling Action Requests )------------------------------------------- */ public function handleActionRequest(AphrontRequest $request) { return new Aphront404Response(); } public function getActionURI($path = null) { $source_id = $this->getSource()->getID(); return '/action/'.$source_id.'/'.ltrim($path, '/'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/source/NuancePhabricatorFormSourceDefinition.php
src/applications/nuance/source/NuancePhabricatorFormSourceDefinition.php
<?php final class NuancePhabricatorFormSourceDefinition extends NuanceSourceDefinition { public function getName() { return pht('Web Form'); } public function getSourceDescription() { return pht('Create a web form that submits into a Nuance queue.'); } public function getSourceTypeConstant() { return 'phabricator-form'; } public function getSourceViewActions(AphrontRequest $request) { $actions = array(); $actions[] = id(new PhabricatorActionView()) ->setName(pht('View Form')) ->setIcon('fa-align-justify') ->setHref($this->getActionURI()); return $actions; } public function handleActionRequest(AphrontRequest $request) { $viewer = $request->getViewer(); // TODO: As above, this would eventually be driven by custom logic. if ($request->isFormPost()) { $properties = array( 'complaint' => (string)$request->getStr('complaint'), ); $content_source = PhabricatorContentSource::newFromRequest($request); $item = $this->newItemFromProperties( NuanceFormItemType::ITEMTYPE, $viewer->getPHID(), $properties, $content_source); $uri = $item->getURI(); return id(new AphrontRedirectResponse())->setURI($uri); } $form = id(new AphrontFormView()) ->setUser($viewer) ->appendRemarkupInstructions( pht('IMPORTANT: This is a very rough prototype.')) ->appendRemarkupInstructions( pht('Got a complaint? Complain here! We love complaints.')) ->appendChild( id(new AphrontFormTextAreaControl()) ->setName('complaint') ->setLabel(pht('Complaint'))) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue(pht('Submit Complaint'))); $box = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Complaint Form')) ->appendChild($form); return $box; } public function renderItemEditProperties( PhabricatorUser $viewer, NuanceItem $item, PHUIPropertyListView $view) { $this->renderItemCommonProperties($viewer, $item, $view); } private function renderItemCommonProperties( PhabricatorUser $viewer, NuanceItem $item, PHUIPropertyListView $view) { $complaint = $item->getItemProperty('complaint'); $complaint = new PHUIRemarkupView($viewer, $complaint); $view->addSectionHeader( pht('Complaint'), 'fa-exclamation-circle'); $view->addTextContent($complaint); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/source/NuanceGitHubRepositorySourceDefinition.php
src/applications/nuance/source/NuanceGitHubRepositorySourceDefinition.php
<?php final class NuanceGitHubRepositorySourceDefinition extends NuanceSourceDefinition { public function getName() { return pht('GitHub Repository'); } public function getSourceDescription() { return pht('Import issues and pull requests from a GitHub repository.'); } public function getSourceTypeConstant() { return 'github.repository'; } public function hasImportCursors() { return true; } protected function newImportCursors() { return array( id(new NuanceGitHubRepositoryImportCursor()) ->setCursorKey('events.repository'), id(new NuanceGitHubIssuesImportCursor()) ->setCursorKey('events.issues'), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/source/__tests__/NuanceSourceDefinitionTestCase.php
src/applications/nuance/source/__tests__/NuanceSourceDefinitionTestCase.php
<?php final class NuanceSourceDefinitionTestCase extends PhabricatorTestCase { public function testGetAllTypes() { NuanceSourceDefinition::getAllDefinitions(); $this->assertTrue(true); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/application/PhabricatorNuanceApplication.php
src/applications/nuance/application/PhabricatorNuanceApplication.php
<?php final class PhabricatorNuanceApplication extends PhabricatorApplication { public function getName() { return pht('Nuance'); } public function getIcon() { return 'fa-fax'; } public function getTitleGlyph() { return "\xE2\x98\x8E"; } public function isPrototype() { return true; } public function getBaseURI() { return '/nuance/'; } public function getShortDescription() { return pht('High-Volume Task Queues'); } public function getRoutes() { return array( '/nuance/' => array( '' => 'NuanceConsoleController', 'item/' => array( $this->getQueryRoutePattern() => 'NuanceItemListController', 'view/(?P<id>[1-9]\d*)/' => 'NuanceItemViewController', 'manage/(?P<id>[1-9]\d*)/' => 'NuanceItemManageController', 'action/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/' => 'NuanceItemActionController', ), 'source/' => array( $this->getQueryRoutePattern() => 'NuanceSourceListController', $this->getEditRoutePattern('edit/') => 'NuanceSourceEditController', 'view/(?P<id>[1-9]\d*)/' => 'NuanceSourceViewController', ), 'queue/' => array( $this->getQueryRoutePattern() => 'NuanceQueueListController', $this->getEditRoutePattern('edit/') => 'NuanceQueueEditController', 'view/(?P<id>[1-9]\d*)/' => 'NuanceQueueViewController', 'work/(?P<id>[1-9]\d*)/' => 'NuanceQueueWorkController', 'action/(?P<queueID>[1-9]\d*)/(?P<action>[^/]+)/(?P<id>[1-9]\d*)/' => 'NuanceItemActionController', ), ), '/action/' => array( '(?P<id>[1-9]\d*)/(?P<path>.*)' => 'NuanceSourceActionController', ), ); } protected function getCustomCapabilities() { return array( NuanceSourceDefaultViewCapability::CAPABILITY => array( 'caption' => pht('Default view policy for newly created sources.'), 'template' => NuanceSourcePHIDType::TYPECONST, 'capability' => PhabricatorPolicyCapability::CAN_VIEW, ), NuanceSourceDefaultEditCapability::CAPABILITY => array( 'caption' => pht('Default edit policy for newly created sources.'), 'template' => NuanceSourcePHIDType::TYPECONST, 'capability' => PhabricatorPolicyCapability::CAN_EDIT, ), NuanceSourceManageCapability::CAPABILITY => array(), ); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/item/NuanceGitHubEventItemType.php
src/applications/nuance/item/NuanceGitHubEventItemType.php
<?php final class NuanceGitHubEventItemType extends NuanceItemType { const ITEMTYPE = 'github.event'; private $externalObject; private $externalActor; public function getItemTypeDisplayName() { return pht('GitHub Event'); } public function getItemTypeDisplayIcon() { return 'fa-github'; } public function getItemDisplayName(NuanceItem $item) { return $this->newRawEvent($item)->getEventFullTitle(); } public function canUpdateItems() { return true; } protected function updateItemFromSource(NuanceItem $item) { $viewer = $this->getViewer(); $is_dirty = false; $xobj = $this->reloadExternalObject($item); if ($xobj) { $item->setItemProperty('doorkeeper.xobj.phid', $xobj->getPHID()); $is_dirty = true; } $actor = $this->reloadExternalActor($item); if ($actor) { $item->setRequestorPHID($actor->getPHID()); $is_dirty = true; } if ($item->getStatus() == NuanceItem::STATUS_IMPORTING) { $item->setStatus(NuanceItem::STATUS_ROUTING); $is_dirty = true; } if ($is_dirty) { $item->save(); } } private function getDoorkeeperActorRef(NuanceItem $item) { $raw = $this->newRawEvent($item); $user_id = $raw->getActorGitHubUserID(); if (!$user_id) { return null; } $ref_type = DoorkeeperBridgeGitHubUser::OBJTYPE_GITHUB_USER; return $this->newDoorkeeperRef() ->setObjectType($ref_type) ->setObjectID($user_id); } private function getDoorkeeperRef(NuanceItem $item) { $raw = $this->newRawEvent($item); $full_repository = $raw->getRepositoryFullName(); if (!strlen($full_repository)) { return null; } if ($raw->isIssueEvent()) { $ref_type = DoorkeeperBridgeGitHubIssue::OBJTYPE_GITHUB_ISSUE; $issue_number = $raw->getIssueNumber(); $full_ref = "{$full_repository}#{$issue_number}"; } else { return null; } return $this->newDoorkeeperRef() ->setObjectType($ref_type) ->setObjectID($full_ref); } private function newDoorkeeperRef() { return id(new DoorkeeperObjectRef()) ->setApplicationType(DoorkeeperBridgeGitHub::APPTYPE_GITHUB) ->setApplicationDomain(DoorkeeperBridgeGitHub::APPDOMAIN_GITHUB); } private function reloadExternalObject(NuanceItem $item, $local = false) { $ref = $this->getDoorkeeperRef($item); if (!$ref) { return null; } $xobj = $this->reloadExternalRef($item, $ref, $local); if ($xobj) { $this->externalObject = $xobj; } return $xobj; } private function reloadExternalActor(NuanceItem $item, $local = false) { $ref = $this->getDoorkeeperActorRef($item); if (!$ref) { return null; } $xobj = $this->reloadExternalRef($item, $ref, $local); if ($xobj) { $this->externalActor = $xobj; } return $xobj; } private function reloadExternalRef( NuanceItem $item, DoorkeeperObjectRef $ref, $local) { $source = $item->getSource(); $token = $source->getSourceProperty('github.token'); $token = new PhutilOpaqueEnvelope($token); $viewer = $this->getViewer(); $ref = id(new DoorkeeperImportEngine()) ->setViewer($viewer) ->setRefs(array($ref)) ->setThrowOnMissingLink(true) ->setContextProperty('github.token', $token) ->needLocalOnly($local) ->executeOne(); if ($ref->getSyncFailed()) { $xobj = null; } else { $xobj = $ref->getExternalObject(); } return $xobj; } private function getExternalObject(NuanceItem $item) { if ($this->externalObject === null) { $xobj = $this->reloadExternalObject($item, $local = true); if ($xobj) { $this->externalObject = $xobj; } else { $this->externalObject = false; } } if ($this->externalObject) { return $this->externalObject; } return null; } private function getExternalActor(NuanceItem $item) { if ($this->externalActor === null) { $xobj = $this->reloadExternalActor($item, $local = true); if ($xobj) { $this->externalActor = $xobj; } else { $this->externalActor = false; } } if ($this->externalActor) { return $this->externalActor; } return null; } private function newRawEvent(NuanceItem $item) { $type = $item->getItemProperty('api.type'); $raw = $item->getItemProperty('api.raw', array()); return NuanceGitHubRawEvent::newEvent($type, $raw); } public function getItemActions(NuanceItem $item) { $actions = array(); $xobj = $this->getExternalObject($item); if ($xobj) { $actions[] = $this->newItemAction($item, 'reload') ->setName(pht('Reload from GitHub')) ->setIcon('fa-refresh') ->setWorkflow(true) ->setRenderAsForm(true); } $actions[] = $this->newItemAction($item, 'sync') ->setName(pht('Import to Maniphest')) ->setIcon('fa-anchor') ->setWorkflow(true) ->setRenderAsForm(true); $actions[] = $this->newItemAction($item, 'raw') ->setName(pht('View Raw Event')) ->setWorkflow(true) ->setIcon('fa-code'); return $actions; } public function getItemCurtainPanels(NuanceItem $item) { $viewer = $this->getViewer(); $panels = array(); $xobj = $this->getExternalObject($item); if ($xobj) { $xobj_phid = $xobj->getPHID(); $task = id(new ManiphestTaskQuery()) ->setViewer($viewer) ->withBridgedObjectPHIDs(array($xobj_phid)) ->executeOne(); if ($task) { $panels[] = $this->newCurtainPanel($item) ->setHeaderText(pht('Imported As')) ->appendChild($viewer->renderHandle($task->getPHID())); } } $xactor = $this->getExternalActor($item); if ($xactor) { $panels[] = $this->newCurtainPanel($item) ->setHeaderText(pht('GitHub Actor')) ->appendChild($viewer->renderHandle($xactor->getPHID())); } return $panels; } protected function handleAction(NuanceItem $item, $action) { $viewer = $this->getViewer(); $controller = $this->getController(); switch ($action) { case 'raw': $raw = array( 'api.type' => $item->getItemProperty('api.type'), 'api.raw' => $item->getItemProperty('api.raw'), ); $raw_output = id(new PhutilJSON())->encodeFormatted($raw); $raw_box = id(new AphrontFormTextAreaControl()) ->setCustomClass('PhabricatorMonospaced') ->setLabel(pht('Raw Event')) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setValue($raw_output); $form = id(new AphrontFormView()) ->appendChild($raw_box); return $controller->newDialog() ->setWidth(AphrontDialogView::WIDTH_FULL) ->setTitle(pht('GitHub Raw Event')) ->appendForm($form) ->addCancelButton($item->getURI(), pht('Done')); case 'sync': case 'reload': $item->issueCommand($viewer->getPHID(), $action); return id(new AphrontRedirectResponse())->setURI($item->getURI()); } return null; } protected function newItemView(NuanceItem $item) { $content = array(); $content[] = $this->newGitHubEventItemPropertyBox($item); return $content; } private function newGitHubEventItemPropertyBox($item) { $viewer = $this->getViewer(); $property_list = id(new PHUIPropertyListView()) ->setViewer($viewer); $event = $this->newRawEvent($item); $property_list->addProperty( pht('GitHub Event ID'), $event->getID()); $event_uri = $event->getURI(); if ($event_uri && PhabricatorEnv::isValidRemoteURIForLink($event_uri)) { $event_uri = phutil_tag( 'a', array( 'href' => $event_uri, 'target' => '_blank', 'rel' => 'noreferrer', ), $event_uri); } if ($event_uri) { $property_list->addProperty( pht('GitHub Event URI'), $event_uri); } return id(new PHUIObjectBoxView()) ->setHeaderText(pht('Event Properties')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($property_list); } protected function handleCommand( NuanceItem $item, NuanceItemCommand $command) { // TODO: This code is no longer reachable, and has moved to // CommandImplementation subclasses. $action = $command->getCommand(); switch ($action) { case 'sync': return $this->syncItem($item, $command); case 'reload': $this->reloadExternalObject($item); return true; } return null; } private function syncItem( NuanceItem $item, NuanceItemCommand $command) { $xobj_phid = $item->getItemProperty('doorkeeper.xobj.phid'); if (!$xobj_phid) { throw new Exception( pht( 'Unable to sync: no external object PHID.')); } // TODO: Write some kind of marker to prevent double-synchronization. $viewer = $this->getViewer(); $xobj = id(new DoorkeeperExternalObjectQuery()) ->setViewer($viewer) ->withPHIDs(array($xobj_phid)) ->executeOne(); if (!$xobj) { throw new Exception( pht( 'Unable to sync: failed to load object "%s".', $xobj_phid)); } $acting_as_phid = $this->getActingAsPHID($item); $xactions = array(); $task = id(new ManiphestTaskQuery()) ->setViewer($viewer) ->withBridgedObjectPHIDs(array($xobj_phid)) ->executeOne(); if (!$task) { $task = ManiphestTask::initializeNewTask($viewer) ->setAuthorPHID($acting_as_phid) ->setBridgedObjectPHID($xobj_phid); $title = $xobj->getProperty('task.title'); if (!strlen($title)) { $title = pht('Nuance Item %d Task', $item->getID()); } $description = $xobj->getProperty('task.description'); $created = $xobj->getProperty('task.created'); $state = $xobj->getProperty('task.state'); $xactions[] = id(new ManiphestTransaction()) ->setTransactionType( ManiphestTaskTitleTransaction::TRANSACTIONTYPE) ->setNewValue($title) ->setDateCreated($created); $xactions[] = id(new ManiphestTransaction()) ->setTransactionType( ManiphestTaskDescriptionTransaction::TRANSACTIONTYPE) ->setNewValue($description) ->setDateCreated($created); $task->setDateCreated($created); // TODO: Synchronize state. } $event = $this->newRawEvent($item); $comment = $event->getComment(); if (strlen($comment)) { $xactions[] = id(new ManiphestTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) ->attachComment( id(new ManiphestTransactionComment()) ->setContent($comment)); } $agent_phid = $command->getAuthorPHID(); $source = $this->newContentSource($item, $agent_phid); $editor = id(new ManiphestTransactionEditor()) ->setActor($viewer) ->setActingAsPHID($acting_as_phid) ->setContentSource($source) ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true); $xactions = $editor->applyTransactions($task, $xactions); return array( 'objectPHID' => $task->getPHID(), 'xactionPHIDs' => mpull($xactions, 'getPHID'), ); } protected function getActingAsPHID(NuanceItem $item) { $actor_phid = $item->getRequestorPHID(); if ($actor_phid) { return $actor_phid; } return parent::getActingAsPHID($item); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/item/NuanceFormItemType.php
src/applications/nuance/item/NuanceFormItemType.php
<?php final class NuanceFormItemType extends NuanceItemType { const ITEMTYPE = 'form.item'; public function getItemTypeDisplayName() { return pht('Form'); } public function getItemDisplayName(NuanceItem $item) { return pht('Complaint'); } protected function newWorkCommands(NuanceItem $item) { return array( $this->newCommand('trash') ->setIcon('fa-trash') ->setName(pht('Throw In Trash')), ); } protected function newItemView(NuanceItem $item) { $viewer = $this->getViewer(); $content = $item->getItemProperty('complaint'); $content_view = id(new PHUIRemarkupView($viewer, $content)) ->setContextObject($item); $content_section = id(new PHUIPropertyListView()) ->addTextContent( phutil_tag( 'div', array( 'class' => 'phabricator-remarkup', ), $content_view)); $content_box = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Complaint')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->appendChild($content_section); return array( $content_box, ); } protected function handleAction(NuanceItem $item, $action) { return null; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/item/NuanceItemType.php
src/applications/nuance/item/NuanceItemType.php
<?php abstract class NuanceItemType extends Phobject { private $viewer; private $controller; public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; } public function getViewer() { return $this->viewer; } public function setController(PhabricatorController $controller) { $this->controller = $controller; return $this; } public function getController() { return $this->controller; } public function canUpdateItems() { return false; } final public function buildItemView(NuanceItem $item) { return $this->newItemView($item); } final public function buildItemWorkView(NuanceItem $item) { return $this->newItemView($item); } protected function newItemView(NuanceItem $item) { return null; } public function getItemTypeDisplayIcon() { return null; } public function getItemActions(NuanceItem $item) { return array(); } public function getItemCurtainPanels(NuanceItem $item) { return array(); } abstract public function getItemTypeDisplayName(); abstract public function getItemDisplayName(NuanceItem $item); final public function updateItem(NuanceItem $item) { if (!$this->canUpdateItems()) { throw new Exception( pht( 'This item type ("%s", of class "%s") can not update items.', $this->getItemTypeConstant(), get_class($this))); } $this->updateItemFromSource($item); } protected function updateItemFromSource(NuanceItem $item) { throw new PhutilMethodNotImplementedException(); } final public function getItemTypeConstant() { return $this->getPhobjectClassConstant('ITEMTYPE', 64); } final public static function getAllItemTypes() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->setUniqueMethod('getItemTypeConstant') ->execute(); } final protected function newItemAction(NuanceItem $item, $key) { $id = $item->getID(); $action_uri = "/nuance/item/action/{$id}/{$key}/"; return id(new PhabricatorActionView()) ->setHref($action_uri); } final protected function newCurtainPanel(NuanceItem $item) { return id(new PHUICurtainPanelView()); } final public function buildActionResponse(NuanceItem $item, $action) { return $this->handleAction($item, $action); } protected function handleAction(NuanceItem $item, $action) { return null; } final public function buildWorkCommands(NuanceItem $item) { return $this->newWorkCommands($item); } final protected function newContentSource( NuanceItem $item, $agent_phid) { return PhabricatorContentSource::newForSource( NuanceContentSource::SOURCECONST, array( 'itemPHID' => $item->getPHID(), 'agentPHID' => $agent_phid, )); } protected function getActingAsPHID(NuanceItem $item) { return id(new PhabricatorNuanceApplication())->getPHID(); } protected function newCommand($command_key) { return id(new NuanceItemCommandSpec()) ->setCommandKey($command_key); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/phid/NuanceImportCursorPHIDType.php
src/applications/nuance/phid/NuanceImportCursorPHIDType.php
<?php final class NuanceImportCursorPHIDType extends PhabricatorPHIDType { const TYPECONST = 'NUAC'; public function getTypeName() { return pht('Import Cursor'); } public function newObject() { return new NuanceImportCursorData(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorNuanceApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new NuanceImportCursorDataQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { $viewer = $query->getViewer(); foreach ($handles as $phid => $handle) { $item = $objects[$phid]; } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/phid/NuanceItemPHIDType.php
src/applications/nuance/phid/NuanceItemPHIDType.php
<?php final class NuanceItemPHIDType extends PhabricatorPHIDType { const TYPECONST = 'NUAI'; public function getTypeName() { return pht('Item'); } public function newObject() { return new NuanceItem(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorNuanceApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new NuanceItemQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { $viewer = $query->getViewer(); foreach ($handles as $phid => $handle) { $item = $objects[$phid]; $handle->setName($item->getDisplayName()); $handle->setURI($item->getURI()); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/phid/NuanceSourcePHIDType.php
src/applications/nuance/phid/NuanceSourcePHIDType.php
<?php final class NuanceSourcePHIDType extends PhabricatorPHIDType { const TYPECONST = 'NUAS'; public function getTypeName() { return pht('Source'); } public function newObject() { return new NuanceSource(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorNuanceApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new NuanceSourceQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { $viewer = $query->getViewer(); foreach ($handles as $phid => $handle) { $source = $objects[$phid]; $handle->setName($source->getName()); $handle->setURI($source->getURI()); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/phid/NuanceQueuePHIDType.php
src/applications/nuance/phid/NuanceQueuePHIDType.php
<?php final class NuanceQueuePHIDType extends PhabricatorPHIDType { const TYPECONST = 'NUAQ'; public function getTypeName() { return pht('Queue'); } public function newObject() { return new NuanceQueue(); } public function getPHIDTypeApplicationClass() { return 'PhabricatorNuanceApplication'; } protected function buildQueryForObjects( PhabricatorObjectQuery $query, array $phids) { return id(new NuanceQueueQuery()) ->withPHIDs($phids); } public function loadHandles( PhabricatorHandleQuery $query, array $handles, array $objects) { $viewer = $query->getViewer(); foreach ($handles as $phid => $handle) { $queue = $objects[$phid]; $handle->setName($queue->getName()); $handle->setURI($queue->getURI()); } } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/conduit/NuanceConduitAPIMethod.php
src/applications/nuance/conduit/NuanceConduitAPIMethod.php
<?php abstract class NuanceConduitAPIMethod extends ConduitAPIMethod { final public function getApplication() { return PhabricatorApplication::getByClass('PhabricatorNuanceApplication'); } public function getMethodStatus() { return self::METHOD_STATUS_UNSTABLE; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/typeahead/NuanceQueueDatasource.php
src/applications/nuance/typeahead/NuanceQueueDatasource.php
<?php final class NuanceQueueDatasource extends PhabricatorTypeaheadDatasource { public function getBrowseTitle() { return pht('Browse Queues'); } public function getPlaceholderText() { return pht('Type a queue name...'); } public function getDatasourceApplicationClass() { return 'PhabricatorNuanceApplication'; } public function loadResults() { $viewer = $this->getViewer(); $raw_query = $this->getRawQuery(); $results = array(); // TODO: Make this use real typeahead logic. $query = new NuanceQueueQuery(); $queues = $this->executeQuery($query); foreach ($queues as $queue) { $results[] = id(new PhabricatorTypeaheadResult()) ->setName($queue->getName()) ->setURI('/nuance/queue/'.$queue->getID().'/') ->setPHID($queue->getPHID()); } return $this->filterResultsAgainstTokens($results); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/capability/NuanceSourceDefaultViewCapability.php
src/applications/nuance/capability/NuanceSourceDefaultViewCapability.php
<?php final class NuanceSourceDefaultViewCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'nuance.source.default.view'; public function getCapabilityName() { return pht('Default Source View Policy'); } public function shouldAllowPublicPolicySetting() { return true; } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/capability/NuanceSourceDefaultEditCapability.php
src/applications/nuance/capability/NuanceSourceDefaultEditCapability.php
<?php final class NuanceSourceDefaultEditCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'nuance.source.default.edit'; public function getCapabilityName() { return pht('Default Source Edit Policy'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false
phacility/phabricator
https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/nuance/capability/NuanceSourceManageCapability.php
src/applications/nuance/capability/NuanceSourceManageCapability.php
<?php final class NuanceSourceManageCapability extends PhabricatorPolicyCapability { const CAPABILITY = 'nuance.source.manage'; public function getCapabilityName() { return pht('Can Manage Sources'); } public function describeCapabilityRejection() { return pht('You do not have permission to manage sources.'); } }
php
Apache-2.0
5720a38cfe95b00ca4be5016dd0d2f3195f4fa04
2026-01-04T15:03:23.651835Z
false