private function canEditInlineComment(PhabricatorUser $user, DifferentialInlineComment $inline)
 {
     // Only the author may edit a comment.
     if ($inline->getAuthorPHID() != $user->getPHID()) {
         return false;
     }
     // Saved comments may not be edited.
     if ($inline->getCommentID()) {
         return false;
     }
     // Inline must be attached to the active revision.
     if ($inline->getRevisionID() != $this->revisionID) {
         return false;
     }
     return true;
 }
 private function canEditInlineComment(PhabricatorUser $user, DifferentialInlineComment $inline)
 {
     // Only the author may edit a comment.
     if ($inline->getAuthorPHID() != $user->getPHID()) {
         return false;
     }
     // Saved comments may not be edited, for now, although the schema now
     // supports it.
     if (!$inline->isDraft()) {
         return false;
     }
     // Inline must be attached to the active revision.
     if ($inline->getRevisionID() != $this->getRevisionID()) {
         return false;
     }
     return true;
 }
 protected function buildInlineInfoDictionary(DifferentialInlineComment $inline, DifferentialChangeset $changeset = null)
 {
     $file_path = null;
     $diff_id = null;
     if ($changeset) {
         $file_path = $inline->getIsNewFile() ? $changeset->getFilename() : $changeset->getOldFile();
         $diff_id = $changeset->getDiffID();
     }
     return array('id' => $inline->getID(), 'authorPHID' => $inline->getAuthorPHID(), 'filePath' => $file_path, 'isNewFile' => $inline->getIsNewFile(), 'lineNumber' => $inline->getLineNumber(), 'lineLength' => $inline->getLineLength(), 'diffID' => $diff_id, 'content' => $inline->getContent());
 }
 public function execute()
 {
     $table = new DifferentialTransactionComment();
     $conn_r = $table->establishConnection('r');
     $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildLimitClause($conn_r));
     $comments = $table->loadAllFromArray($data);
     foreach ($comments as $key => $value) {
         $comments[$key] = DifferentialInlineComment::newFromModernComment($value);
     }
     return $comments;
 }
 public function execute()
 {
     $table = new DifferentialTransactionComment();
     $conn_r = $table->establishConnection('r');
     $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildLimitClause($conn_r));
     $comments = $table->loadAllFromArray($data);
     if ($this->needHidden) {
         $viewer_phid = $this->getViewer()->getPHID();
         if ($viewer_phid && $comments) {
             $hidden = queryfx_all($conn_r, 'SELECT commentID FROM %T WHERE userPHID = %s
         AND commentID IN (%Ls)', id(new DifferentialHiddenComment())->getTableName(), $viewer_phid, mpull($comments, 'getID'));
             $hidden = array_fuse(ipull($hidden, 'commentID'));
         } else {
             $hidden = array();
         }
         foreach ($comments as $inline) {
             $inline->attachIsHidden(isset($hidden[$inline->getID()]));
         }
     }
     foreach ($comments as $key => $value) {
         $comments[$key] = DifferentialInlineComment::newFromModernComment($value);
     }
     return $comments;
 }
 public function willRenderTimeline(PhabricatorApplicationTransactionView $timeline, AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $render_data = $timeline->getRenderData();
     $left = $request->getInt('left', idx($render_data, 'left'));
     $right = $request->getInt('right', idx($render_data, 'right'));
     $diffs = id(new DifferentialDiffQuery())->setViewer($request->getUser())->withIDs(array($left, $right))->execute();
     $diffs = mpull($diffs, null, 'getID');
     $left_diff = $diffs[$left];
     $right_diff = $diffs[$right];
     $old_ids = $request->getStr('old', idx($render_data, 'old'));
     $new_ids = $request->getStr('new', idx($render_data, 'new'));
     $old_ids = array_filter(explode(',', $old_ids));
     $new_ids = array_filter(explode(',', $new_ids));
     $type_inline = DifferentialTransaction::TYPE_INLINE;
     $changeset_ids = array_merge($old_ids, $new_ids);
     $inlines = array();
     foreach ($timeline->getTransactions() as $xaction) {
         if ($xaction->getTransactionType() == $type_inline) {
             $inlines[] = $xaction->getComment();
             $changeset_ids[] = $xaction->getComment()->getChangesetID();
         }
     }
     if ($changeset_ids) {
         $changesets = id(new DifferentialChangesetQuery())->setViewer($request->getUser())->withIDs($changeset_ids)->execute();
         $changesets = mpull($changesets, null, 'getID');
     } else {
         $changesets = array();
     }
     foreach ($inlines as $key => $inline) {
         $inlines[$key] = DifferentialInlineComment::newFromModernComment($inline);
     }
     $query = id(new DifferentialInlineCommentQuery())->needHidden(true)->setViewer($viewer);
     // NOTE: This is a bit sketchy: this method adjusts the inlines as a
     // side effect, which means it will ultimately adjust the transaction
     // comments and affect timeline rendering.
     $query->adjustInlinesForChangesets($inlines, array_select_keys($changesets, $old_ids), array_select_keys($changesets, $new_ids), $this);
     return $timeline->setChangesets($changesets)->setRevision($this)->setLeftDiff($left_diff)->setRightDiff($right_diff);
 }
 private function buildLintInlineComments($changeset)
 {
     $lint = id(new DifferentialDiffProperty())->loadOneWhere('diffID = %d AND name = %s', $changeset->getDiffID(), 'arc:lint');
     if (!$lint) {
         return array();
     }
     $lint = $lint->getData();
     $inlines = array();
     foreach ($lint as $msg) {
         if ($msg['path'] != $changeset->getFilename()) {
             continue;
         }
         $inline = new DifferentialInlineComment();
         $inline->setChangesetID($changeset->getID());
         $inline->setIsNewFile(true);
         $inline->setSyntheticAuthor('Lint: ' . $msg['name']);
         $inline->setLineNumber($msg['line']);
         $inline->setLineLength(0);
         $inline->setContent('%%%' . $msg['description'] . '%%%');
         $inlines[] = $inline;
     }
     return $inlines;
 }
 private function renderInlineComment(DifferentialInlineComment $comment)
 {
     $user = $this->user;
     $edit = $user && $comment->getAuthorPHID() == $user->getPHID() && !$comment->getCommentID();
     $on_right = $this->isCommentOnRightSideWhenDisplayed($comment);
     return id(new DifferentialInlineCommentView())->setInlineComment($comment)->setOnRight($on_right)->setHandles($this->handles)->setMarkupEngine($this->markupEngine)->setEditable($edit)->render();
 }
Beispiel #9
0
    $table = new DifferentialChangeset();
    if ($changesets) {
        echo "Purging changeset cache for changesets " . implode($changesets, ",") . "\n";
        queryfx($table->establishConnection('w'), 'DELETE FROM %T WHERE id IN (%Ld)', DifferentialChangeset::TABLE_CACHE, $changesets);
    } else {
        echo "Purging changeset cache...\n";
        queryfx($table->establishConnection('w'), 'TRUNCATE TABLE %T', DifferentialChangeset::TABLE_CACHE);
    }
    echo "Done.\n";
}
if ($purge_differential) {
    echo "Purging Differential comment cache...\n";
    $table = new DifferentialComment();
    queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName());
    echo "Purging Differential inline comment cache...\n";
    $table = new DifferentialInlineComment();
    queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName());
    echo "Done.\n";
}
if ($purge_maniphest) {
    echo "Purging Maniphest comment cache...\n";
    $table = new ManiphestTransaction();
    queryfx($table->establishConnection('w'), 'UPDATE %T SET cache = NULL', $table->getTableName());
    echo "Done.\n";
}
echo "Ok, caches purged.\n";
function usage($message)
{
    echo "Usage Error: {$message}";
    echo "\n\n";
    echo "Run 'purge_cache.php --help' for detailed help.\n";