function trySubmit() { global $wgOut, $wgUser; $errors = array(); $ip = $this->mUnblockIP; if (!IP::isIPAddress($ip) && strlen($ip)) { $errors[] = array('globalblocking-unblock-ipinvalid', $ip); $ip = ''; } if (0 == ($id = GlobalBlocking::getGlobalBlockId($ip))) { $errors[] = array('globalblocking-notblocked', $ip); } if (count($errors) > 0) { return $errors; } $dbw = GlobalBlocking::getGlobalBlockingMaster(); $dbw->delete('globalblocks', array('gb_id' => $id), __METHOD__); $page = new LogPage('gblblock'); $page->addEntry('gunblock', Title::makeTitleSafe(NS_USER, $ip), $this->mReason); $successmsg = wfMsgExt('globalblocking-unblock-unblocked', array('parse'), $ip, $id); $wgOut->addHTML($successmsg); $link = $wgUser->getSkin()->makeKnownLinkObj(SpecialPage::getTitleFor('GlobalBlockList'), wfMsg('globalblocking-return')); $wgOut->addHTML($link); $wgOut->setSubtitle(wfMsg('globalblocking-unblock-successsub')); return array(); }
function execute($par) { global $wgRequest, $wgSitename, $wgLanguageCode; global $wgDeferredUpdateList, $wgOut, $wgUser, $wgServer; $fname = "wfChangerealname"; if (!$wgUser->isAllowed('changerealname')) { $wgOut->permissionRequired('changerealname'); return; } if ($wgRequest->wasPosted()) { if ($wgRequest->getVal('target') && $wgRequest->getVal('realname')) { // $dbw = wfGetDB(DB_MASTER); $user = User::newFromName($wgRequest->getVal('target')); if ($user->getId() == 0) { $wgOut->addHTML(wfMsg('changerealname_nouser', $user->getName())); return; } //yeah...if you could not go straight to the database, that'd be great... [sc] // $oldname = $dbw->selectField( 'user', 'user_real_name', array('user_name'=>$wgRequest->getVal('target')) ); // $dbw->update('user', array('user_real_name' => $wgRequest->getVal('realname')), array('user_name'=>$wgRequest->getVal('target'))); $oldname = $user->getRealName(); $user->setRealName($wgRequest->getVal('realname')); $user->saveSettings(); $summary = wfMsg('changerealname_summary', $wgUser->getName(), $user->getName(), $oldname, $wgRequest->getVal('realname')); $log = new LogPage('realname', true); $log->addEntry('realname', $user->getUserPage(), $summary); $wgOut->addHTML(wfMsg('changerealname_success')); } } else { $me = Title::makeTitle(NS_SPECIAL, "Changerealname"); $wgOut->addHTML("<form method='POST' action='{$me->getFullURL()}'>\n\t\t\t\t\tUsername: <input type='text' name='target'><br/><br/>\n\t\t\t\t\tNew real name: <input type='text' name='realname'><br/>\n\t\t\t\t\t<input type='submit' value='" . wfMsg('changerealname_submit') . "'>\n\t\t\t\t</form>"); } }
function wfNewuserlogAutoCreate($user) { wfLoadExtensionMessages('Newuserlog'); $log = new LogPage('newusers'); $log->addEntry('autocreate', $user->getUserPage(), '', array($user->getId())); return true; }
function wfNewuserlogHook($user) { global $wgUser, $wgContLang, $wgVersion; if (is_null($user)) { // Compatibility with old versions which didn't pass the parameter $user = $wgUser; } $talk = $wgContLang->getFormattedNsText(NS_TALK); $contribs = wfMsgForContent('contribslink'); $block = wfMsgForContent('blocklink'); if ($user->getName() == $wgUser->getName()) { $message = ''; $action = 'create'; } else { // Links not necessary for self-creations, they will appear already in // recentchanges and special:log view for the creating user. // For compatability: From 1.10alpha the 'user tools' are used at special:log // see bug 4756: Long usernames break block link in new user log entries $action = 'create2'; if (version_compare($wgVersion, '1.10alpha', '>=')) { $message = ''; } else { $message = wfMsgForContent('newuserlog-create-text', $user->getName(), $talk, $contribs, $block); } } $log = new LogPage('newusers'); $log->addEntry($action, $user->getUserPage(), $message); return true; }
public function logFeedback($params, $itemId) { $title = SpecialPage::getTitleFor('FeedbackDashboard', $itemId); $reason = wfMessage('moodbar-log-reason')->params($params['type'], $params['comment'])->text(); $log = new LogPage('moodbar'); $log->addEntry('feedback', $title, $reason); }
public function hUnwatchArticleComplete(&$user, &$article) { $message = wfMsgForContent('watchlog-unwatch-text', $article->mTitle->getPrefixedText()); $log = new LogPage('watchlog'); $log->addEntry('unwatchok', $user->getUserPage(), $message); return true; }
function logRestore($itemId, $low, $hi, $reason, $count) { $title = $this->makeTitle($itemId); $params = array($itemId, $low, $hi); $log = new LogPage($this->logType, true); $log->addEntry($this->logType, $title, wfMsg('clearratings_logrestore', $reason, $title->getFullText(), $count), $params); }
/** * After a page is saved, add or remove it from the blank_page table if * it has been blanked or unblanked, respectively; if blanked, redirect * the user to the "Action complete" page */ public static function PureWikiDeletionSaveCompleteHook(&$article, &$user, $text, $summary, $minoredit, &$watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId, &$redirect) { global $wgOut, $wgInterWikiIntegrationInEffect; if (!isset($revision)) { return true; } $mTitle = $article->getTitle(); if ($mTitle->getNamespace() == NS_FILE) { return true; } $blankRevId = $revision->getId(); if ($text == "") { if ($summary == wfMsgForContent('autosumm-blank')) { $hasHistory = false; $summary = $article->generateReason($hasHistory); } $dbw = wfGetDB(DB_MASTER); $blank_row = array('blank_page_id' => $article->getID(), 'blank_user_id' => $user->getId(), 'blank_user_name' => $user->getName(), 'blank_timestamp' => $revision->getTimeStamp(), 'blank_summary' => $summary, 'blank_parent_id' => $revision->getParentId()); $dbw->insert('blanked_page', $blank_row); $log = new LogPage('blank'); $log->addEntry('blank', $mTitle, $summary, array(), $user); $dbw->commit(); $dbw->delete('recentchanges', array('rc_this_oldid' => $blankRevId)); Article::onArticleDelete($mTitle); $mTitle->resetArticleID(0); if ($user->getOption('watchblank')) { $watchthis = true; } wfRunHooks('PureWikiDeletionArticleBlankComplete', array($mTitle)); $redirect = false; $wgOut->setPagetitle(wfMsg('actioncomplete')); $wgOut->setRobotPolicy('noindex,nofollow'); $loglink = wfMsg('blank-log-link'); $wgOut->addWikiMsg('purewikideletion-blankedtext', $mTitle->getPrefixedText(), $loglink); $wgOut->returnToMain(false); } else { $dbr = wfGetDB(DB_SLAVE); $blank_page_id = $article->getID(); $result = $dbr->selectRow('blanked_page', 'blank_page_id', array("blank_page_id" => $blank_page_id)); if (!$result) { return true; } else { if ($summary == '') { $summary = $article->getAutosummary('', $text, EDIT_NEW); } $dbw = wfGetDB(DB_MASTER); $blank_page_id = $article->getID(); $dbw->delete('blanked_page', array("blank_page_id" => $blank_page_id)); $log = new LogPage('blank'); $log->addEntry('unblank', $mTitle, $summary, array(), $user); $dbw->commit(); $dbw->delete('recentchanges', array('rc_this_oldid' => $blankRevId)); $mTitle->touchLinks(); $mTitle->invalidateCache(); $mTitle->purgeSquid(); wfRunHooks('PureWikiDeletionArticleUnblankComplete', array($mTitle)); } } return true; }
public function execute() { global $wgUser, $wgTranslateWorkflowStates; if (!$wgTranslateWorkflowStates) { $this->dieUsage('Message group review not in use', 'disabled'); } if (!$wgUser->isallowed(self::$right)) { $this->dieUsage('Permission denied', 'permissiondenied'); } $requestParams = $this->extractRequestParams(); $group = MessageGroups::getGroup($requestParams['group']); if (!$group) { $this->dieUsageMsg(array('missingparam', 'group')); } $languages = Language::getLanguageNames(false); if (!isset($languages[$requestParams['language']])) { $this->dieUsageMsg(array('missingparam', 'language')); } $dbr = wfGetDB(DB_SLAVE); $groupid = $group->getId(); $currentState = $dbr->selectField('translate_groupreviews', 'tgr_state', array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language']), __METHOD__); if ($currentState == $requestParams['state']) { $this->dieUsage('The requested state is identical to the current state', 'sameworkflowstate'); } $dbw = wfGetDB(DB_MASTER); $table = 'translate_groupreviews'; $row = array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language'], 'tgr_state' => $requestParams['state']); $index = array('tgr_group', 'tgr_language'); $res = $dbw->replace($table, array($index), $row, __METHOD__); $logger = new LogPage('translationreview'); $logParams = array($requestParams['language'], $group->getLabel(), $currentState, $requestParams['state']); $logger->addEntry('group', SpecialPage::getTitleFor('Translate', $groupid), '', $logParams, $wgUser); $output = array('review' => array('group' => $group->getId(), 'language' => $requestParams['language'], 'state' => $requestParams['state'])); $this->getResult()->addValue(null, $this->getModuleName(), $output); }
function logRestore($itemId, $low, $hi, $reason, $count) { $title = Title::newFromId($itemId); $params = array($itemId, $low, $hi); $log = new LogPage('accuracy', true); $log->addEntry($this->logType, $title, wfMessage('clearratings_logrestore', $reason, $title->getFullText(), $count)->text(), $params); }
function dropDocent($user) { global $dbw, $debug, $project_page; if (!$debug) { $dbw->query("delete from docentcategories where dc_user={$user->getId()}"); } $params = array($user->getID()); $log = new LogPage('doc', false); $log->addEntry('doc', $project_page, wfMsg('doc_logsummary', $user->getName()), $params); }
function wfUserLoginLogoutComplete($user) { global $wgUser, $wgUserBeforeLogout; $tmp = $wgUser->mId; $wgUser->mId = $wgUserBeforeLogout->getId(); $log = new LogPage('userlogin', false); $log->addEntry('logout', $wgUserBeforeLogout->getUserPage(), $user->getName()); $wgUser->mId = $tmp; return true; }
public function hEmailUserComplete($to, $from, $subject, $text) { global $wgUser; $toname = $to->name; $fromname = $from->name; $message = wfMsgForContent('emaillog-sent-text', $fromname, $toname); $log = new LogPage('emaillog'); $log->addEntry('sentok', $wgUser->getUserPage(), $message); return true; }
/** * Show the special page * * @param $user Mixed: parameter passed to the page or null */ public function execute($par) { global $wgUploadAvatarInRecentChanges; $out = $this->getOutput(); $request = $this->getRequest(); $user = $this->getUser(); // If the user isn't logged in, display an error if (!$user->isLoggedIn()) { $this->displayRestrictionError(); return; } // If the user doesn't have 'avatarremove' permission, display an error if (!$user->isAllowed('avatarremove')) { $this->displayRestrictionError(); return; } // Show a message if the database is in read-only mode if (wfReadOnly()) { $out->readOnlyPage(); return; } // If user is blocked, s/he doesn't need to access this page if ($user->isBlocked()) { $out->blockedPage(); return; } // Set the page title, robot policies, etc. $this->setHeaders(); $out->setPageTitle($this->msg('avatarupload-removeavatar')->plain()); if ($request->getVal('user') != '') { $out->redirect($this->getPageTitle()->getFullURL() . '/' . $request->getVal('user')); } // If the request was POSTed, then delete the avatar if ($request->wasPosted()) { $user_id = $request->getInt('user_id'); $user_deleted = User::newFromId($user_id); $this->deleteImage($user_id, 's'); $this->deleteImage($user_id, 'm'); $this->deleteImage($user_id, 'l'); $this->deleteImage($user_id, 'ml'); $log = new LogPage('avatar'); if (!$wgUploadAvatarInRecentChanges) { $log->updateRecentChanges = false; } $log->addEntry('avatar', $user->getUserPage(), $this->msg('user-profile-picture-log-delete-entry', $user_deleted->getName())->inContentLanguage()->text()); $out->addHTML('<div>' . $this->msg('avatarupload-removesuccess')->plain() . '</div>'); $out->addHTML('<div><a href="' . htmlspecialchars($this->getPageTitle()->getFullURL()) . '">' . $this->msg('avatarupload-removeanother')->plain() . '</a></div>'); } else { if ($par) { $out->addHTML($this->showUserAvatar($par)); } else { $out->addHTML($this->showUserForm()); } } }
function run() { global $wgUser; // Initialization $title = $this->title; // Other stuff $user = $this->getUser(); $summary = $this->getSummary(); $base = $this->getBase(); PageTranslationHooks::$allowTargetEdit = true; $oldUser = $wgUser; $wgUser = $user; $error = ''; $article = new Article( $title, 0 ); $ok = $article->doDeleteArticle( $summary, false, 0, true, $error ); if ( !$ok ) { $logger = new LogPage( 'pagetranslation' ); $params = array( 'user' => $this->getPerformer(), 'target' => $base, 'error' => base64_encode( serialize( $ok ) ), // This is getting ridiculous ); $doer = User::newFromName( $this->getPerformer() ); $msg = $this->getFull() ? 'deletefnok' : 'deletelnok'; $logger->addEntry( $msg, $title, null, array( serialize( $params ) ), $doer ); } PageTranslationHooks::$allowTargetEdit = false; $cache = wfGetCache( CACHE_DB ); $pages = (array) $cache->get( wfMemcKey( 'pt-base', $base ) ); $lastitem = array_pop( $pages ); if ( $title->getPrefixedText() === $lastitem ) { $cache->delete( wfMemcKey( 'pt-base', $base ) ); $logger = new LogPage( 'pagetranslation' ); $params = array( 'user' => $this->getPerformer() ); $doer = User::newFromName( $this->getPerformer() ); $msg = $this->getFull() ? 'deletefok' : 'deletelok'; $logger->addEntry( $msg, Title::newFromText( $base ), null, array( serialize( $params ) ), $doer ); $tpage = TranslatablePage::newFromTitle( $title ); $tpage->getTranslationPercentages( true ); foreach ( $tpage->getTranslationPages() as $page ) { $page->invalidateCache(); } $title->invalidateCache(); } $wgUser = $oldUser; return true; }
public function execute() { global $wgUser; if ( !$wgUser->isallowed( self::$right ) ) { $this->dieUsage( 'Permission denied', 'permissiondenied' ); } $params = $this->extractRequestParams(); $revision = Revision::newFromId( $params['revision'] ); if ( !$revision ) { $this->dieUsage( 'Invalid revision', 'invalidrevision' ); } $title = $revision->getTitle(); $handle = new MessageHandle( $title ); if ( !$handle->isValid() ) { $this->dieUsage( 'Unknown message', 'unknownmessage' ); } if ( $handle->isFuzzy() ) { $this->dieUsage( 'Cannot review fuzzy translations', 'fuzzymessage' ); } if ( $revision->getUser() == $wgUser->getId() ) { $this->dieUsage( 'Cannot review own translations', 'owntranslation' ); } $dbw = wfGetDB( DB_MASTER ); $table = 'translate_reviews'; $row = array( 'trr_user' => $wgUser->getId(), 'trr_page' => $revision->getPage(), 'trr_revision' => $revision->getId(), ); $options = array( 'IGNORE' ); $res = $dbw->insert( $table, $row, __METHOD__, $options ); if ( !$dbw->affectedRows() ) { $this->setWarning( 'Already marked as reviewed by you' ); } else { $logger = new LogPage( 'translationreview' ); $params = array( $revision->getId() ); $logger->addEntry( 'message', $title, null, $params, $wgUser ); } $output = array( 'review' => array( 'title' => $title->getPrefixedText(), 'pageid' => $revision->getPage(), 'revision' => $revision->getId() ) ); $this->getResult()->addValue( null, $this->getModuleName(), $output ); }
/** * Show the special page * * @param $user Mixed: parameter passed to the page or null */ public function execute($user) { global $wgUser, $wgOut, $wgRequest, $wgUploadAvatarInRecentChanges; $this->title = SpecialPage::getTitleFor('RemoveAvatar'); // If the user isn't logged in, display an error if (!$wgUser->isLoggedIn()) { $this->displayRestrictionError(); return; } // If the user doesn't have 'avatarremove' permission, display an error if (!$wgUser->isAllowed('avatarremove')) { $this->displayRestrictionError(); return; } // Show a message if the database is in read-only mode if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } // If user is blocked, s/he doesn't need to access this page if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } $wgOut->setPageTitle(wfMsg('avatarupload-removeavatar')); if ($wgRequest->getVal('user') != '') { $wgOut->redirect($this->title->getFullURL() . '/' . $wgRequest->getVal('user')); } // If the request was POSTed, then delete the avatar if ($wgRequest->wasPosted()) { $user_id = $wgRequest->getInt('user_id'); $user_deleted = User::newFromId($user_id); $user_deleted->loadFromDatabase(); $this->deleteImage($user_id, 's'); $this->deleteImage($user_id, 'm'); $this->deleteImage($user_id, 'l'); $this->deleteImage($user_id, 'ml'); $log = new LogPage(wfMsgForContent('user-profile-picture-log')); if (!$wgUploadAvatarInRecentChanges) { $log->updateRecentChanges = false; } $log->addEntry(wfMsg('user-profile-picture-log'), $wgUser->getUserPage(), wfMsg('user-profile-picture-log-delete-entry', $user_deleted->getName())); $wgOut->addHTML('<div>' . wfMsg('avatarupload-removesuccess') . '</div>'); $wgOut->addHTML('<div><a href="' . $this->title->escapeFullURL() . '">' . wfMsg('avatarupload-removeanother') . '</a></div>'); } else { if ($user) { $wgOut->addHTML($this->showUserAvatar($user)); } else { $wgOut->addHTML($this->showUserForm()); } } }
/** * Show some text and linkage on successful upload. * * @param $ext String: file extension (gif, jpg or png) */ private function showSuccess($ext) { global $wgAvatarKey, $wgUploadPath, $wgUploadAvatarInRecentChanges; $user = $this->getUser(); $log = new LogPage('avatar'); if (!$wgUploadAvatarInRecentChanges) { $log->updateRecentChanges = false; } $log->addEntry('avatar', $user->getUserPage(), $this->msg('user-profile-picture-log-entry')->inContentLanguage()->text()); $uid = $user->getId(); $output = '<h1>' . $this->msg('uploadavatar')->plain() . '</h1>'; $output .= UserProfile::getEditProfileNav($this->msg('user-profile-section-picture')->plain()); $output .= '<div class="profile-info">'; $output .= '<p class="profile-update-title">' . $this->msg('user-profile-picture-yourpicture')->plain() . '</p>'; $output .= '<p>' . $this->msg('user-profile-picture-yourpicturestext')->plain() . '</p>'; $output .= '<table cellspacing="0" cellpadding="0" style="margin-top:20px;">'; $output .= '<tr> <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' . $this->msg('user-profile-picture-large')->plain() . '</td> <td style="padding-bottom:20px;"> <img src="' . $wgUploadPath . '/avatars/' . $wgAvatarKey . '_' . $uid . '_l.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> </td> </tr>'; $output .= '<tr> <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' . $this->msg('user-profile-picture-medlarge')->plain() . '</td> <td style="padding-bottom:20px;"> <img src="' . $wgUploadPath . '/avatars/' . $wgAvatarKey . '_' . $uid . '_ml.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> </td> </tr>'; $output .= '<tr> <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' . $this->msg('user-profile-picture-medium')->plain() . '</td> <td style="padding-bottom:20px;"> <img src="' . $wgUploadPath . '/avatars/' . $wgAvatarKey . '_' . $uid . '_m.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> </td> </tr>'; $output .= '<tr> <td valign="top" style="color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;">' . $this->msg('user-profile-picture-small')->plain() . '</td> <td style="padding-bottom:20px;"> <img src="' . $wgUploadPath . '/avatars/' . $wgAvatarKey . '_' . $uid . '_s.' . $ext . '?ts=' . rand() . '" alt="" border="0" /> </td> </tr>'; $output .= '<tr> <td> <input type="button" onclick="javascript:history.go(-1)" class="site-button" value="' . $this->msg('user-profile-picture-uploaddifferent')->plain() . '" /> </td> </tr>'; $output .= '</table>'; $output .= '</div>'; $this->getOutput()->addHTML($output); }
function wfSpecialRemoveRestrictionsProcess($r) { global $wgUser, $wgRequest; $reason = $wgRequest->getVal('reason'); $result = $r->delete(); $log = new LogPage('restrict'); $params = array($r->getType()); if ($r->isPage()) { $params[] = $r->getPage()->getPrefixedDbKey(); } if ($r->isNamespace()) { $params[] = $r->getNamespace(); } $log->addEntry('remove', Title::makeTitle(NS_USER, $r->getSubjectText()), $reason, $params); return $result; }
/** * Task for adding logs about changed flags to Special:Log and Special:RecentChanges * It adds one log per changed flag * * Task need to be run in wikia context (where flags were changed) to store in local logging table in DB - * invoke ->wikiId( ... ) method before queuing task. * * @param array $flags list of flags changed, each item of that list is an array with flag fields as items * @param int $pageId ID of article where flags were changed * @param string $actionType Type of action performed on flag represented by constants in \FlagsApiController class */ public function logFlagChange(array $flags, $pageId, $actionType) { $app = \F::app(); $wikiaFlagTypesResponse = $app->sendRequest('FlagsApiController', 'getFlagTypes', [], true, \WikiaRequest::EXCEPTION_MODE_RETURN); $wikiaFlagTypes = $wikiaFlagTypesResponse->getData(); if ($wikiaFlagTypes['status'] === true) { foreach ($flags as $i => $flag) { $flagTypeId = $flag['flag_type_id']; $title = \Title::newFromID($pageId); /* Log info about changes */ $log = new \LogPage('flags'); $log->addEntry($actionType, $title, '', [$wikiaFlagTypes['data'][$flagTypeId]['flag_name']], $this->createdByUser()); } } else { $this->error("No flags types found for wikia (city_id:{$this->getWikiId()})"); } }
/** * Record a log event for a change being patrolled * * @param $rc Mixed: change identifier or RecentChange object * @param $auto Boolean: was this patrol event automatic? */ public static function record($rc, $auto = false) { if (!$rc instanceof RecentChange) { $rc = RecentChange::newFromId($rc); if (!is_object($rc)) { return false; } } $title = Title::makeTitleSafe($rc->getAttribute('rc_namespace'), $rc->getAttribute('rc_title')); if (is_object($title)) { $params = self::buildParams($rc, $auto); $log = new LogPage('patrol', false, $auto ? "skipUDP" : "UDP"); # False suppresses RC entries $log->addEntry('patrol', $title, '', $params); return true; } return false; }
/** * Process the 'delvote' action. * @param Article $article The article to endorse/object to deletion of. */ public function process($article) { global $wgRequest, $wgOut, $wgUser; $errs = $article->mTitle->getUserPermissionsErrors('deletequeue-vote', $wgUser); if (count($errs) > 0) { $wgOut->showPermissionsErrorPage($errs); return; } $dqi = DeleteQueueItem::newFromArticle($article); $wgOut->setPageTitle(wfMsg('deletequeue-vote-title', $article->mTitle->getPrefixedText())); // Load form data $token = $wgRequest->getVal('wpEditToken'); $action = $wgRequest->getVal('wpVote'); $comments = $wgRequest->getText('wpComments'); if ($wgUser->matchEditToken($token) && in_array($action, array('endorse', 'object'))) { $dqi->addVote($action, $comments); if ($action == 'object' && $dqi->getQueue() == 'prod') { $dbw = wfGetDB(DB_MASTER); $dbw->begin(); $dqi->setQueue('deletediscuss', $dqi->getReason()); $lp = new LogPage('delete'); $lp->addEntry('requeue', $article->mTitle, $comments, array(wfMsgForContent('deletequeue-queue-prod'), wfMsgForContent("deletequeue-queue-deletediscuss"))); $dbw->commit(); $wgOut->addWikiMsg('deletequeue-vote-requeued', wfMsgNoTrans('deletequeue-queue-deletediscuss')); } else { $wgOut->addWikiMsg("deletequeue-vote-success-{$action}"); } return; } $wgOut->addWikiMsg('deletequeue-vote-text', $article->mTitle->getPrefixedText(), $dqi->getReason()); // Add main form. $fields = array(); $options = Xml::tags('p', null, Xml::radioLabel(wfMsg('deletequeue-vote-endorse'), 'wpVote', 'endorse', 'mw-deletequeue-vote-endorse')); $options .= Xml::tags('p', null, Xml::radioLabel(wfMsg('deletequeue-vote-object'), 'wpVote', 'object', 'mw-deletequeue-vote-object')); $fields['deletequeue-vote-action'] = $options; $fields['deletequeue-vote-reason'] = Xml::input('wpComments', 45, $comments); $article_id = $article->getId(); $title = $this->getTitle("vote/{$article_id}"); $form = Xml::buildForm($fields, 'deletequeue-vote-submit') . Html::Hidden('wpEditToken', $wgUser->editToken()) . Html::Hidden('title', $title->getPrefixedText()); $form = Xml::tags('form', array('action' => $title->getLocalURL(), 'method' => 'POST'), $form); $form = Xml::fieldset(wfMsg('deletequeue-vote-legend'), $form); $wgOut->addHTML($form); }
function checkProxy($title, $user, $action, &$result) { global $wgProxyCanPerform, $wgAutoProxyBlockLog; if (in_array($action, $wgProxyCanPerform) || $user->isAllowed('proxyunbannable')) { return true; } $userIP = wfGetIP(); if (self::isProxy($userIP)) { if ($wgAutoProxyBlockLog) { $log = new LogPage('proxyblock'); $log->addEntry('blocked', $title, false, array($action, $user->getName())); // hack for 1.19- $dbw = wfGetDB(DB_MASTER); $blocker = User::newFromName('AutoProxyBlock'); $dbw->update('logging', array('log_user' => $blocker->getID(), 'log_user_text' => 'AutoProxyBlock'), array('log_type' => 'proxyblock', 'log_user_text' => $user->getName()), __METHOD__, array('ORDER BY' => 'log_timestamp DESC')); } $result[] = array('proxy-blocked', $userIP); return false; } return true; }
function doSubmit() { global $wgOut; $block = new Block(); $this->ip = trim($this->ip); if ($this->ip[0] == "#") { $block->mId = substr($this->ip, 1); } else { $block->mAddress = $this->ip; } # Delete block (if it exists) # We should probably check for errors rather than just declaring success $block->delete(); # Make log entry $log = new LogPage('block'); $log->addEntry('unblock', Title::makeTitle(NS_USER, $this->ip), $this->reason); # Report to the user $titleObj = Title::makeTitle(NS_SPECIAL, "Ipblocklist"); $success = $titleObj->getFullURL("action=success&ip=" . urlencode($this->ip)); $wgOut->redirect($success); }
public function hUserSettingsChanged(&$user) { // case 1: new account creation // Just bail out. global $wgUser; if ($wgUser->getID() == 0) { return true; } // Case 2: // we need some protection against multiple saves per transaction. // SpecialPreferences.php does multiple saves regularly... static $firstTimePassed = false; if ($firstTimePassed === false) { $firstTimePassed = true; return true; } $title = $user->getUserPage(); $message = wfMsgForContent('usetchglog' . '-save-text', $user->mName); $log = new LogPage('usetchglog'); $log->addEntry('saveok', $title, $message); return true; }
/** * Hook: add premium video and clear cache (video embed tool, video service) * @param Title $title * @return true */ public static function onAddPremiumVideo($title) { if ($title instanceof Title) { $videoInfoHelper = new VideoInfoHelper(); $videoInfo = $videoInfoHelper->getVideoInfoFromTitle($title, true); if (!empty($videoInfo)) { // Sometimes videoInfo doesn't reflect what's actually in the video_info table // so make sure the removed flag is cleared $videoInfo->restoreVideo(); $affected = $videoInfo->addPremiumVideo(F::app()->wg->User->getId()); if ($affected) { # Add a log entry $log = new LogPage('upload'); $comment = wfMessage('videohandler-log-add-video')->plain(); $log->addEntry('upload', $title, $comment, array(), F::app()->wg->User); $mediaService = new MediaQueryService(); $mediaService->clearCacheTotalVideos(); $mediaService->clearCacheTotalPremiumVideos(); } } } return true; }
/** * Create a log entry using the provided info. * Takes care about the logging interface changes in MediaWiki 1.19. * * @since 0.1 * * @param array $info */ public static function log(array $info) { $user = array_key_exists('user', $info) ? $info['user'] : $GLOBALS['wgUser']; if ($info !== false) { if (class_exists('ManualLogEntry')) { $logEntry = new ManualLogEntry($info['type'], $info['subtype']); $logEntry->setPerformer($user); $logEntry->setTarget($info['title']); if (array_key_exists('comment', $info)) { $logEntry->setComment($info['comment']); } if (array_key_exists('parameters', $info)) { $logEntry->setParameters($info['parameters']); } $logid = $logEntry->insert(); $logEntry->publish($logid); } else { // Compatibility with MediaWiki 1.18. $log = new LogPage($info['type']); $log->addEntry($info['subtype'], $info['title'], array_key_exists('comment', $info) ? $info['comment'] : '', array_key_exists('parameters', $info) ? $info['parameters'] : array(), $user); } } }
/** * Show the special page * * @param mixed $par Parameter passed to the page */ public function execute($par) { global $wgOut, $wgUser, $wgTitle, $wgRequest, $wgContLang, $wgLang; global $wgVersion, $wgMaxNameChars, $wgCapitalLinks; $this->setHeaders(); if (!$wgUser->isAllowed('renameuser')) { $wgOut->permissionRequired('renameuser'); return; } if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } $showBlockLog = $wgRequest->getBool('submit-showBlockLog'); $oldusername = Title::newFromText($wgRequest->getText('oldusername'), NS_USER); $newusername = Title::newFromText($wgContLang->ucfirst($wgRequest->getText('newusername')), NS_USER); // Force uppercase of newusername otherweise wikis with wgCapitalLinks=false can create lc usernames $oun = is_object($oldusername) ? $oldusername->getText() : ''; $nun = is_object($newusername) ? $newusername->getText() : ''; $token = $wgUser->editToken(); $reason = $wgRequest->getText('reason'); $is_checked = true; if ($wgRequest->wasPosted() && !$wgRequest->getCheck('movepages')) { $is_checked = false; } $wgOut->addHTML("\n\t\t\t<!-- Current contributions limit is " . RENAMEUSER_CONTRIBLIMIT . " -->" . Xml::openElement('form', array('method' => 'post', 'action' => $wgTitle->getLocalUrl(), 'id' => 'renameuser')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('renameuser')) . Xml::openElement('table', array('id' => 'mw-renameuser-table')) . "<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('renameuserold'), 'oldusername') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('oldusername', 20, $oun, array('type' => 'text', 'tabindex' => '1')) . ' ' . Xml::submitButton(wfMsg('blocklogpage'), array('name' => 'submit-showBlockLog', 'id' => 'submit-showBlockLog', 'tabindex' => '2')) . ' ' . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('renameusernew'), 'newusername') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('newusername', 20, $nun, array('type' => 'text', 'tabindex' => '3')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('renameuserreason'), 'reason') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('reason', 40, $reason, array('type' => 'text', 'tabindex' => '4', 'maxlength' => 255)) . "</td>\n\t\t\t</tr>"); if ($wgUser->isAllowed('move') && version_compare($wgVersion, '1.9alpha', '>=')) { $wgOut->addHTML("\n\t\t\t\t<tr>\n\t\t\t\t\t<td> \n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('renameusermove'), 'movepages', 'movepages', $is_checked, array('tabindex' => '5')) . "</td>\n\t\t\t\t</tr>"); } $wgOut->addHTML("\n\t\t\t<tr>\n\t\t\t\t<td> \n\t\t\t\t</td>\n\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('renameusersubmit'), array('name' => 'submit', 'tabindex' => '6', 'id' => 'submit')) . "</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('fieldset') . Xml::hidden('token', $token) . Xml::closeElement('form') . "\n"); // Show block log if requested if ($showBlockLog && is_object($oldusername)) { $this->showLogExtract($oldusername, 'block', $wgOut); return; } if ($wgRequest->getText('token') === '') { # They probably haven't even submitted the form, so don't go further. return; } elseif (!$wgRequest->wasPosted() || !$wgUser->matchEditToken($wgRequest->getVal('token'))) { $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameuser-error-request') . "</div>"); return; } elseif (!is_object($oldusername)) { // FIXME: This is bogus. Invalid titles need to be rename-able! (bug 12654) $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameusererrorinvalid', $wgRequest->getText('oldusername')) . "</div>"); return; } elseif (!is_object($newusername)) { $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameusererrorinvalid', $wgRequest->getText('newusername')) . "</div>"); return; } elseif ($oldusername->getText() == $newusername->getText()) { $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameuser-error-same-user') . "</div>"); return; } // Suppress username validation of old username $olduser = User::newFromName($oldusername->getText(), false); $newuser = User::newFromName($newusername->getText()); // It won't be an object if for instance "|" is supplied as a value if (!is_object($olduser)) { $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameusererrorinvalid', $oldusername->getText()) . "</div>"); return; } if (!is_object($newuser) || !User::isCreatableName($newuser->getName())) { $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameusererrorinvalid', $newusername->getText()) . "</div>"); return; } // Check for the existence of lowercase oldusername in database. // Until r19631 it was possible to rename a user to a name with first character as lowercase if ($wgRequest->getText('oldusername') !== $wgContLang->ucfirst($wgRequest->getText('oldusername'))) { // oldusername was entered as lowercase -> check for existence in table 'user' $dbr_lc = wfGetDB(DB_SLAVE); $s = trim($wgRequest->getText('oldusername')); $uid = $dbr_lc->selectField('user', 'user_id', array('BINARY user_name' => $s), __METHOD__); if ($uid === false) { $uid = 0; # if ( !$wgCapitalLinks ) { # $uid = 0; // We are on a lowercase wiki but lowercase username does not exists # } else { # $uid = $olduser->idForName(); // We are on a standard uppercase wiki, use normal # } } else { // username with lowercase exists // Title::newFromText was nice, but forces uppercase // for older rename accidents on lowercase wikis we need the lowercase username as entered in the form $oldusername->mTextform = $wgRequest->getText('oldusername'); $oldusername->mUrlform = $wgRequest->getText('oldusername'); $oldusername->mDbkeyform = $wgRequest->getText('oldusername'); } } else { // oldusername was entered as upperase -> standard procedure $uid = $olduser->idForName(); } if ($uid == 0) { $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameusererrordoesnotexist', $wgRequest->getText('oldusername')) . "</div>"); return; } if ($newuser->idForName() != 0) { $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameusererrorexists', $newusername->getText()) . "</div>"); return; } // Always get the edits count, it will be used for the log message $contribs = User::edits($uid); // Check edit count if (!$wgUser->isAllowed('siteadmin')) { if (RENAMEUSER_CONTRIBLIMIT != 0 && $contribs > RENAMEUSER_CONTRIBLIMIT) { $wgOut->addWikiText("<div class=\"errorbox\">" . wfMsg('renameusererrortoomany', $oldusername->getText(), $wgLang->formatNum($contribs), $wgLang->formatNum(RENAMEUSER_CONTRIBLIMIT)) . "</div>"); return; } } // Give other affected extensions a chance to validate or abort if (!wfRunHooks('RenameUserAbort', array($uid, $oldusername->getText(), $newusername->getText()))) { return; } $rename = new RenameuserSQL($oldusername->getText(), $newusername->getText(), $uid); $rename->rename(); $log = new LogPage('renameuser'); $log->addEntry('renameuser', $oldusername, wfMsgExt('renameuser-log', array('parsemag', 'content'), $wgContLang->formatNum($contribs), $reason), $newusername->getText()); $wgOut->addWikiText("<div class=\"successbox\">" . wfMsg('renameusersuccess', $oldusername->getText(), $newusername->getText()) . "</div><br style=\"clear:both\" />"); if ($wgRequest->getCheck('movepages') && $wgUser->isAllowed('move') && version_compare($wgVersion, '1.9alpha', '>=')) { $dbr =& wfGetDB(DB_SLAVE); $oldkey = $oldusername->getDBkey(); $pages = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace IN (' . NS_USER . ',' . NS_USER_TALK . ')', '(page_title LIKE ' . $dbr->addQuotes($dbr->escapeLike($oldusername->getDBkey()) . '/%') . ' OR page_title = ' . $dbr->addQuotes($oldusername->getDBkey()) . ')'), __METHOD__); $output = ''; $skin =& $wgUser->getSkin(); while ($row = $dbr->fetchObject($pages)) { $oldPage = Title::makeTitleSafe($row->page_namespace, $row->page_title); $newPage = Title::makeTitleSafe($row->page_namespace, preg_replace('!^[^/]+!', $newusername->getDBkey(), $row->page_title)); if ($newPage->exists() && !$oldPage->isValidMoveTarget($newPage)) { $link = $skin->makeKnownLinkObj($newPage); $output .= '<li class="mw-renameuser-pe">' . wfMsgHtml('renameuser-page-exists', $link) . '</li>'; } else { $success = $oldPage->moveTo($newPage, false, wfMsgForContent('renameuser-move-log', $oldusername->getText(), $newusername->getText())); if ($success === true) { $oldLink = $skin->makeKnownLinkObj($oldPage, '', 'redirect=no'); $newLink = $skin->makeKnownLinkObj($newPage); $output .= '<li class="mw-renameuser-pm">' . wfMsgHtml('renameuser-page-moved', $oldLink, $newLink) . '</li>'; } else { $oldLink = $skin->makeKnownLinkObj($oldPage); $newLink = $skin->makeLinkObj($newPage); $output .= '<li class="mw-renameuser-pu">' . wfMsgHtml('renameuser-page-unmoved', $oldLink, $newLink) . '</li>'; } } } if ($output) { $wgOut->addHtml('<ul>' . $output . '</ul>'); } } }
/** * Update the article's restriction field, and leave a log entry. * This works for protection both existing and non-existing pages. * * @param array $limit set of restriction keys * @param array $expiry per restriction type expiration * @param int &$cascade Set to false if cascading protection isn't allowed. * @param string $reason * @param User $user The user updating the restrictions * @return Status */ public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) { global $wgCascadingRestrictionLevels; if ( wfReadOnly() ) { return Status::newFatal( 'readonlytext', wfReadOnlyReason() ); } $restrictionTypes = $this->mTitle->getRestrictionTypes(); $id = $this->getId(); if ( !$cascade ) { $cascade = false; } // Take this opportunity to purge out expired restrictions Title::purgeExpiredRestrictions(); // @todo FIXME: Same limitations as described in ProtectionForm.php (line 37); // we expect a single selection, but the schema allows otherwise. $isProtected = false; $protect = false; $changed = false; $dbw = wfGetDB( DB_MASTER ); foreach ( $restrictionTypes as $action ) { if ( !isset( $expiry[$action] ) ) { $expiry[$action] = $dbw->getInfinity(); } if ( !isset( $limit[$action] ) ) { $limit[$action] = ''; } elseif ( $limit[$action] != '' ) { $protect = true; } // Get current restrictions on $action $current = implode( '', $this->mTitle->getRestrictions( $action ) ); if ( $current != '' ) { $isProtected = true; } if ( $limit[$action] != $current ) { $changed = true; } elseif ( $limit[$action] != '' ) { // Only check expiry change if the action is actually being // protected, since expiry does nothing on an not-protected // action. if ( $this->mTitle->getRestrictionExpiry( $action ) != $expiry[$action] ) { $changed = true; } } } if ( !$changed && $protect && $this->mTitle->areRestrictionsCascading() != $cascade ) { $changed = true; } // If nothing has changed, do nothing if ( !$changed ) { return Status::newGood(); } if ( !$protect ) { // No protection at all means unprotection $revCommentMsg = 'unprotectedarticle'; $logAction = 'unprotect'; } elseif ( $isProtected ) { $revCommentMsg = 'modifiedarticleprotection'; $logAction = 'modify'; } else { $revCommentMsg = 'protectedarticle'; $logAction = 'protect'; } if ( $id ) { // Protection of existing page if ( !wfRunHooks( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) { return Status::newGood(); } // Only certain restrictions can cascade... $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' ); foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) { $editrestriction[$key] = 'editprotected'; // backwards compatibility } foreach ( array_keys( $editrestriction, 'autoconfirmed' ) as $key ) { $editrestriction[$key] = 'editsemiprotected'; // backwards compatibility } $cascadingRestrictionLevels = $wgCascadingRestrictionLevels; foreach ( array_keys( $cascadingRestrictionLevels, 'sysop' ) as $key ) { $cascadingRestrictionLevels[$key] = 'editprotected'; // backwards compatibility } foreach ( array_keys( $cascadingRestrictionLevels, 'autoconfirmed' ) as $key ) { $cascadingRestrictionLevels[$key] = 'editsemiprotected'; // backwards compatibility } // The schema allows multiple restrictions if ( !array_intersect( $editrestriction, $cascadingRestrictionLevels ) ) { $cascade = false; } // insert null revision to identify the page protection change as edit summary $latest = $this->getLatest(); $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason ); if ( $nullRevision === null ) { return Status::newFatal( 'no-null-revision', $this->mTitle->getPrefixedText() ); } // Update restrictions table foreach ( $limit as $action => $restrictions ) { if ( $restrictions != '' ) { $dbw->replace( 'page_restrictions', array( array( 'pr_page', 'pr_type' ) ), array( 'pr_page' => $id, 'pr_type' => $action, 'pr_level' => $restrictions, 'pr_cascade' => ( $cascade && $action == 'edit' ) ? 1 : 0, 'pr_expiry' => $dbw->encodeExpiry( $expiry[$action] ) ), __METHOD__ ); } else { $dbw->delete( 'page_restrictions', array( 'pr_page' => $id, 'pr_type' => $action ), __METHOD__ ); } } // Clear out legacy restriction fields $dbw->update( 'page', array( 'page_restrictions' => '' ), array( 'page_id' => $id ), __METHOD__ ); wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $nullRevision, $latest, $user ) ); wfRunHooks( 'ArticleProtectComplete', array( &$this, &$user, $limit, $reason ) ); } else { // Protection of non-existing page (also known as "title protection") // Cascade protection is meaningless in this case $cascade = false; if ( $limit['create'] != '' ) { $dbw->replace( 'protected_titles', array( array( 'pt_namespace', 'pt_title' ) ), array( 'pt_namespace' => $this->mTitle->getNamespace(), 'pt_title' => $this->mTitle->getDBkey(), 'pt_create_perm' => $limit['create'], 'pt_timestamp' => $dbw->encodeExpiry( wfTimestampNow() ), 'pt_expiry' => $dbw->encodeExpiry( $expiry['create'] ), 'pt_user' => $user->getId(), 'pt_reason' => $reason, ), __METHOD__ ); } else { $dbw->delete( 'protected_titles', array( 'pt_namespace' => $this->mTitle->getNamespace(), 'pt_title' => $this->mTitle->getDBkey() ), __METHOD__ ); } } $this->mTitle->flushRestrictions(); InfoAction::invalidateCache( $this->mTitle ); if ( $logAction == 'unprotect' ) { $params = array(); } else { $protectDescriptionLog = $this->protectDescriptionLog( $limit, $expiry ); $params = array( $protectDescriptionLog, $cascade ? 'cascade' : '' ); } // Update the protection log $log = new LogPage( 'protect' ); $log->addEntry( $logAction, $this->mTitle, trim( $reason ), $params, $user ); return Status::newGood(); }
/** * Log wikiset changes * * @param $group string * @param $old string * @param $new string * @param $reason string */ function addWikiSetLog($group, $old, $new, $reason) { $log = new LogPage('gblrights'); $log->addEntry('groupprms3', SpecialPage::getTitleFor('GlobalUsers', $group), $reason, array($this->getWikiSetName($old), $this->getWikiSetName($new))); }