public function execute() { global $wgRequest, $wgWikiLoveLogging, $wgParser; $params = $this->extractRequestParams(); $title = Title::newFromText($params['title']); if (is_null($title)) { $this->dieUsageMsg(array('invaliduser', $params['title'])); } $talk = WikiLoveHooks::getUserTalkPage($title); if (is_null($talk)) { $this->dieUsageMsg(array('invaliduser', $params['title'])); } if ($wgWikiLoveLogging) { $this->saveInDb($talk, $params['subject'], $params['message'], $params['type'], isset($params['email']) ? 1 : 0); } // not using section => 'new' here, as we like to give our own edit summary $api = new ApiMain(new DerivativeRequest($wgRequest, array('action' => 'edit', 'title' => $talk->getFullText(), 'appendtext' => ($talk->exists() ? "\n\n" : '') . wfMsgForContent('newsectionheaderdefaultlevel', $params['subject']) . "\n\n" . $params['text'], 'token' => $params['token'], 'summary' => wfMsgForContent('wikilove-summary', $wgParser->stripSectionName($params['subject'])), 'notminor' => true), false), true); $api->execute(); if (isset($params['email'])) { $this->emailUser($talk, $params['subject'], $params['email'], $params['token']); } $this->getResult()->addValue('redirect', 'pageName', $talk->getPrefixedDBkey()); $this->getResult()->addValue('redirect', 'fragment', Title::escapeFragmentForURL($params['subject'])); // note that we cannot use Title::makeTitle here as it doesn't sanitize the fragment }
/** * Adds the required module if we are on a user (talk) page. * * @param $out OutputPage * @param $skin Skin * * @return true */ public static function beforePageDisplay( $out, $skin ) { global $wgWikiLoveGlobal, $wgUser; if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) { return true; } $title = self::getUserTalkPage( $skin->getTitle() ); if ( !is_null( $title ) ) { $out->addModules( array( 'ext.wikiLove.icon', 'ext.wikiLove.init' ) ); self::$recipient = $title->getBaseText(); } return true; }