예제 #1
0
 function execute()
 {
     global $wgRequest, $wgOut, $wgUser;
     if (!$wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
         $wgOut->addHTML('<strong>' . wfMsg('sessionfailure') . '</strong>');
         parent::execute();
         return;
     }
     if (!$this->mRev) {
         parent::execute();
         return;
     }
     $commentId = $this->revisionUpdate($this->mStatus, $this->mAddTags, $this->mRemoveTags, $this->mSignoffFlags, $this->mStrikeSignoffs, $this->mAddReferences, $this->mRemoveReferences, $this->text, $wgRequest->getIntOrNull('wpParent'), $wgRequest->getInt('wpReview'), $this->mAddReferenced, $this->mRemoveReferenced);
     $redirTarget = null;
     // For comments, take us back to the rev page focused on the new comment
     if ($commentId !== 0 && !$this->jumpToNext) {
         $redirTarget = $this->commentLink($commentId);
     }
     // Return to rev page
     if (!$redirTarget) {
         // Was "next" (or "save & next") clicked?
         if ($this->jumpToNext) {
             $next = $this->mRev->getNextUnresolved($this->mPath);
             if ($next) {
                 $redirTarget = SpecialPage::getTitleFor('Code', $this->mRepo->getName() . '/' . $next);
             } else {
                 $redirTarget = SpecialPage::getTitleFor('Code', $this->mRepo->getName());
             }
         } else {
             # $redirTarget already set for comments
             $redirTarget = $this->revLink();
         }
     }
     $wgOut->redirect($redirTarget->getFullUrl(array('path' => $this->mPath)));
 }
예제 #2
0
 public function execute()
 {
     global $wgUser;
     // Before doing anything at all, let's check permissions
     if (!$wgUser->isAllowed('codereview-use')) {
         $this->dieUsage('You don\'t have permission to update code', 'permissiondenied');
     }
     $params = $this->extractRequestParams();
     if ($params['comment'] && !$wgUser->isAllowed('codereview-post-comment')) {
         $this->dieUsage('You do not have permission to post comment', 'permissiondenied');
     }
     global $wgCodeReviewInlineComments;
     if (!$wgCodeReviewInlineComments && isset($params['patchline'])) {
         $this->dieUsageMsg("Can not attach a comment to a diff when inline commenting is disabled (\$wgCodeReviewInlineComments is false).");
     }
     $repo = CodeRepository::newFromName($params['repo']);
     if (!$repo) {
         $this->dieUsage("Invalid repo ``{$params['repo']}''", 'invalidrepo');
     }
     $rev = $repo->getRevision($params['rev']);
     if (!$rev) {
         $this->dieUsage("There is no revision with ID {$params['rev']}", 'nosuchrev');
     }
     $revisionCommitter = new CodeRevisionCommitterApi($repo, $rev);
     $commentID = $revisionCommitter->revisionUpdate($params['status'], $params['addtags'], $params['removetags'], $params['addflags'], $params['removeflags'], $params['addreferences'], $params['removereferences'], $params['comment'], $params['addreferenced'], $params['removereferenced']);
     // Forge a response object
     $r = array('result' => 'Success');
     if ($commentID !== 0) {
         // id inserted
         $r['commentid'] = intval($commentID);
         // HTML Formatted comment
         $view = new CodeRevisionView($repo, $rev);
         $comment = CodeComment::newFromID($commentID, $rev);
         $r['HTML'] = $view->formatComment($comment);
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $r);
 }
예제 #3
0
 /**
  * @param SvnRevTablePager $pager
  * @return string
  */
 protected function buildBatchInterface($pager)
 {
     global $wgUser;
     $changeFields = array();
     if ($wgUser->isAllowed('codereview-set-status')) {
         $changeFields['code-batch-status'] = Xml::tags('select', array('name' => 'wpStatus'), Xml::tags('option', array('value' => '', 'selected' => 'selected'), ' ') . CodeRevisionView::buildStatusList(null, $this));
     }
     if ($wgUser->isAllowed('codereview-add-tag')) {
         $changeFields['code-batch-tags'] = CodeRevisionView::addTagForm('', '');
     }
     if (!count($changeFields)) {
         return '';
         // nothing to do here
     }
     $changeInterface = Xml::fieldset(wfMsg('codereview-batch-title'), Xml::buildForm($changeFields, 'codereview-batch-submit'));
     $changeInterface .= $pager->getHiddenFields();
     $changeInterface .= Html::hidden('wpBatchChangeEditToken', $wgUser->editToken());
     return $changeInterface;
 }