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>");
     }
 }
Beispiel #3
0
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);
 }
Beispiel #5
0
function wfNewuserlogAutoCreate($user)
{
    wfLoadExtensionMessages('Newuserlog');
    $log = new LogPage('newusers');
    $log->addEntry('autocreate', $user->getUserPage(), '', array($user->getId()));
    return true;
}
 /**
  * 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;
 }
Beispiel #7
0
 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);
 }
Beispiel #8
0
 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;
 }
Beispiel #9
0
 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);
 }
Beispiel #10
0
 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 getLogTitle($rc)
 {
     $logtype = $rc->getAttribute('rc_log_type');
     $logpage = new LogPage($logtype);
     $logname = $logpage->getName()->escaped();
     $titleObj = SpecialPage::getTitleFor('Log', $logtype);
     return '(' . $this->skin->makeKnownLinkObj($titleObj, $logname) . ')';
 }
Beispiel #12
0
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;
}
Beispiel #14
0
 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);
    }
 /**
  * Hook function for RecentChange_save
  * Saves user data into the cu_changes table
  */
 public static function updateCheckUserData(RecentChange $rc)
 {
     global $wgRequest;
     // Extract params
     extract($rc->mAttribs);
     // Get IP
     $ip = wfGetIP();
     // Get XFF header
     $xff = $wgRequest->getHeader('X-Forwarded-For');
     list($xff_ip, $isSquidOnly) = self::getClientIPfromXFF($xff);
     // Get agent
     $agent = $wgRequest->getHeader('User-Agent');
     // Store the log action text for log events
     // $rc_comment should just be the log_comment
     // BC: check if log_type and log_action exists
     // If not, then $rc_comment is the actiontext and comment
     if (isset($rc_log_type) && $rc_type == RC_LOG) {
         $target = Title::makeTitle($rc_namespace, $rc_title);
         $actionText = LogPage::actionText($rc_log_type, $rc_log_action, $target, null, LogPage::extractParams($rc_params));
     } else {
         $actionText = '';
     }
     $dbw = wfGetDB(DB_MASTER);
     $cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq');
     $rcRow = array('cuc_id' => $cuc_id, 'cuc_namespace' => $rc_namespace, 'cuc_title' => $rc_title, 'cuc_minor' => $rc_minor, 'cuc_user' => $rc_user, 'cuc_user_text' => $rc_user_text, 'cuc_actiontext' => $actionText, 'cuc_comment' => $rc_comment, 'cuc_this_oldid' => $rc_this_oldid, 'cuc_last_oldid' => $rc_last_oldid, 'cuc_type' => $rc_type, 'cuc_timestamp' => $rc_timestamp, 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => !$isSquidOnly ? $xff : '', 'cuc_xff_hex' => $xff_ip && !$isSquidOnly ? IP::toHex($xff_ip) : null, 'cuc_agent' => $agent);
     # On PG, MW unsets cur_id due to schema incompatibilites. So it may not be set!
     if (isset($rc_cur_id)) {
         $rcRow['cuc_page_id'] = $rc_cur_id;
     }
     $dbw->insert('cu_changes', $rcRow, __METHOD__);
     return true;
 }
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;
}
Beispiel #22
0
 /**
  * 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()})");
     }
 }
Beispiel #23
0
 /**
  * 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;
 }
	function run() {
		global $wgUser;

		// Initialization
		$title = $this->title;
		// Other stuff
		$user    = $this->getUser();
		$summary = $this->getSummary();
		$target  = $this->getTarget();
		$base    = $this->params['base-source'];

		PageTranslationHooks::$allowTargetEdit = true;
		$oldUser = $wgUser;
		$wgUser = $user;
		self::forceRedirects( false );

		// Don't check perms, don't leave a redirect
		$ok = $title->moveTo( $target, false, $summary, false );
		if ( !$ok ) {
			$logger = new LogPage( 'pagetranslation' );
			$params = array(
				'user' => $this->getPerformer(),
				'target' => $target->getPrefixedText(),
				'error' => base64_encode( serialize( $ok ) ), // This is getting ridiculous
			);
			$doer = User::newFromName( $this->getPerformer() );
			$logger->addEntry( 'movenok', $title, null, array( serialize( $params ) ), $doer );
		}

		self::forceRedirects( true );
		PageTranslationHooks::$allowTargetEdit = false;

		$this->unlock();


		$cache = wfGetCache( CACHE_ANYTHING );
		$key = wfMemcKey( 'translate-pt-move', $base );

		$count = $cache->decr( $key );
		$last = strval( $count ) === "0";

		if ( $last )  {
			$cache->delete( $key );
			$logger = new LogPage( 'pagetranslation' );
			$params = array(
				'user' => $this->getPerformer(),
				'target' => $this->params['base-target'],
			);
			$doer = User::newFromName( $this->getPerformer() );
			$logger->addEntry( 'moveok', Title::newFromText( $base ), null, array( serialize( $params ) ), $doer );
		}

		$wgUser = $oldUser;

		return true;
	}
 /**
  * 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;
 }
Beispiel #27
0
 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);
         }
     }
 }