[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/audit/editor/ -> PhabricatorAuditCommentEditor.php (source)

   1  <?php
   2  
   3  final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
   4  
   5    /**
   6     * Load the PHIDs for all objects the user has the authority to act as an
   7     * audit for. This includes themselves, and any packages they are an owner
   8     * of.
   9     */
  10    public static function loadAuditPHIDsForUser(PhabricatorUser $user) {
  11      $phids = array();
  12  
  13      // TODO: This method doesn't really use the right viewer, but in practice we
  14      // never issue this query of this type on behalf of another user and are
  15      // unlikely to do so in the future. This entire method should be refactored
  16      // into a Query class, however, and then we should use a proper viewer.
  17  
  18      // The user can audit on their own behalf.
  19      $phids[$user->getPHID()] = true;
  20  
  21      $owned_packages = id(new PhabricatorOwnersPackageQuery())
  22        ->setViewer($user)
  23        ->withOwnerPHIDs(array($user->getPHID()))
  24        ->execute();
  25      foreach ($owned_packages as $package) {
  26        $phids[$package->getPHID()] = true;
  27      }
  28  
  29      // The user can audit on behalf of all projects they are a member of.
  30      $projects = id(new PhabricatorProjectQuery())
  31        ->setViewer($user)
  32        ->withMemberPHIDs(array($user->getPHID()))
  33        ->execute();
  34      foreach ($projects as $project) {
  35        $phids[$project->getPHID()] = true;
  36      }
  37  
  38      return array_keys($phids);
  39    }
  40  
  41    public static function newReplyHandlerForCommit($commit) {
  42      $reply_handler = PhabricatorEnv::newObjectFromConfig(
  43        'metamta.diffusion.reply-handler');
  44      $reply_handler->setMailReceiver($commit);
  45      return $reply_handler;
  46    }
  47  
  48    public static function getMailThreading(
  49      PhabricatorRepository $repository,
  50      PhabricatorRepositoryCommit $commit) {
  51  
  52      return array(
  53        'diffusion-audit-'.$commit->getPHID(),
  54        'Commit r'.$repository->getCallsign().$commit->getCommitIdentifier(),
  55      );
  56    }
  57  
  58  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1