function validateSubject($target)
 {
     if (!$target) {
         return wfMsgExt('lqt_split_nosubject', 'parseinline');
     }
     $title = null;
     $article = $this->mThread->article();
     $ok = Thread::validateSubject($target, $title, null, $article);
     if (!$ok) {
         return wfMsgExt('lqt_split_badsubject', 'parseinline');
     }
     return true;
 }
Beispiel #2
0
 /**
  * @param $thread Thread
  */
 function showPostEditingForm($thread)
 {
     $submitted_nonce = $this->request->getVal('lqt_nonce');
     $nonce_key = wfMemcKey('lqt-nonce', $submitted_nonce, $this->user->getName());
     if (!$this->handleNonce($submitted_nonce, $nonce_key)) {
         return;
     }
     $html = Xml::openElement('div', array('class' => 'lqt-edit-form'));
     $this->output->addHTML($html);
     $subject = $this->request->getVal('lqt_subject_field', '');
     if (!$subject) {
         $subject = $thread->subject();
     }
     $t = null;
     $subjectOk = Thread::validateSubject($subject, $t, $thread->superthread(), $this->article);
     if (!$subjectOk) {
         $subject = false;
     }
     $article = $thread->root();
     $talkpage = $thread->article();
     Hooks::run('LiquidThreadsEditFormContent', array($thread, &$article, $talkpage));
     LqtHooks::$editTalkpage = $talkpage;
     LqtHooks::$editArticle = $article;
     LqtHooks::$editThread = $thread;
     LqtHooks::$editType = 'edit';
     LqtHooks::$editAppliesTo = $thread;
     $e = new EditPage($article);
     global $wgRequest;
     // Quietly force a preview if no subject has been specified.
     if (!$subjectOk) {
         // Dirty hack to prevent saving from going ahead
         $wgRequest->setVal('wpPreview', true);
         if ($this->request->wasPosted()) {
             $e->editFormPageTop .= Xml::tags('div', array('class' => 'error'), wfMessage('lqt_invalid_subject')->parse());
         }
     }
     // Add an offset so it works if it's on the wrong page.
     $dbr = wfGetDB(DB_SLAVE);
     $offset = wfTimestamp(TS_UNIX, $thread->topmostThread()->sortkey());
     $offset++;
     $offset = $dbr->timestamp($offset);
     $e->suppressIntro = true;
     $e->editFormTextBeforeContent .= $this->perpetuate('lqt_method', 'hidden') . $this->perpetuate('lqt_operand', 'hidden') . Html::hidden('lqt_nonce', MWCryptRand::generateHex(32)) . Html::hidden('offset', $offset);
     list($signatureEditor, $signatureHTML) = $this->getSignatureEditor($thread);
     $e->editFormTextAfterContent .= $signatureEditor;
     $e->previewTextAfterContent .= Xml::tags('p', null, $signatureHTML);
     if ($thread->isTopmostThread()) {
         $e->editFormTextBeforeContent .= $this->getSubjectEditor($thread->subject(), $subject);
     }
     $e->edit();
     if ($e->didSave) {
         $bump = !$this->request->getCheck('wpBumpThread') || $this->request->getBool('wpBumpThread');
         $signature = $this->request->getVal('wpLqtSignature', null);
         LqtView::editMetadataUpdates(array('thread' => $thread, 'text' => $e->textbox1, 'summary' => $e->summary, 'bump' => $bump, 'subject' => $subject, 'signature' => $signature, 'root' => $article));
         if ($submitted_nonce && $nonce_key) {
             global $wgMemc;
             $wgMemc->set($nonce_key, 1, 3600);
         }
     }
     if ($this->output->getRedirect() != '') {
         $redirectTitle = clone $talkpage->getTitle();
         $redirectTitle->setFragment('#' . $this->anchorName($thread));
         $this->output->redirect($this->title->getLocalURL());
     }
     $this->output->addHTML('</div>');
 }
Beispiel #3
0
 public function actionSetSubject($threads, $params)
 {
     // Validate thread parameter
     if (count($threads) > 1) {
         $this->dieUsage('You may only change the subject of one thread at a time', 'too-many-threads');
     } elseif (count($threads) < 1) {
         $this->dieUsage('You must specify a thread to change the subject of', 'no-specified-threads');
     }
     $thread = array_pop($threads);
     $errors = $thread->title()->getUserPermissionsErrors('edit', $this->getUser());
     if ($errors) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg(reset($errors));
     }
     // Validate subject
     if (empty($params['subject'])) {
         $this->dieUsageMsg(array('missingparam', 'subject'));
     }
     $talkpage = $thread->article();
     $subject = $params['subject'];
     $title = null;
     $subjectOk = Thread::validateSubject($subject, $title, null, $talkpage);
     if (!$subjectOk) {
         $this->dieUsage('The subject you specified is not valid', 'invalid-subject');
     }
     $reason = null;
     if (isset($params['reason'])) {
         $reason = $params['reason'];
     }
     if ($thread->dbVersion->subject() !== $subject) {
         $thread->setSubject($subject);
         $thread->commitRevision(Threads::CHANGE_EDITED_SUBJECT, $thread, $reason);
     }
     $result = array('action' => 'setsubject', 'result' => 'success', 'thread-id' => $thread->id(), 'thread-title' => $thread->title()->getPrefixedText(), 'new-subject' => $subject);
     $result = array('thread' => $result);
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }