Пример #1
0
	/**
	 * Add 'translate-pref-nonewsletter' preference.
	 * This is most probably specific to translatewiki.net. Can be enabled
	 * with $wgTranslateNewsletterPreference.
	 *
	 * @param $user User
	 * @param $preferences array
	 * @return bool true
	 */
	public static function onGetPreferences( $user, &$preferences ) {
		global $wgTranslateNewsletterPreference;

		if ( !$wgTranslateNewsletterPreference ) {
			return true;
		}

		global $wgEnableEmail, $wgEnotifRevealEditorAddress;

		// Only show if e-mail is enabled and user has a confirmed e-mail address.
		if ( $wgEnableEmail && $user->isEmailConfirmed() ) {
			// 'translate-pref-nonewsletter' is used as opt-out for
			// users with a confirmed e-mail address
			$prefs = array(
				'translate-nonewsletter' => array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'translate-pref-nonewsletter'
				)
			);

			// Add setting after 'enotifrevealaddr'.
			$preferences = wfArrayInsertAfter( $preferences, $prefs,
				$wgEnotifRevealEditorAddress ? 'enotifrevealaddr' : 'enotifminoredits' );
		}

		return true;
	}
	/**
	 * Add preferences
	 * @param $user User
	 * @param $preferences array
	 * @return true
	 */
	static function onGetPreferences( $user, &$preferences ) {
		global $wmincPref, $wmincProjects, $wmincProjectSite,
			$wmincLangCodeLength, $wgDefaultUserOptions;

		$preferences['language']['help-message'] = 'wminc-prefinfo-language';

		$prefinsert[$wmincPref . '-project'] = array(
			'type' => 'select',
			'options' =>
				array( wfMsg( 'wminc-testwiki-none' ) => 'none' ) +
				array_flip( $wmincProjects ) +
				array( $wmincProjectSite['name'] => $wmincProjectSite['short'] ),
			'section' => 'personal/i18n',
			'label-message' => 'wminc-testwiki',
			'id' => $wmincPref . '-project',
			'help-message' => 'wminc-prefinfo-project',
		);
		$prefinsert[$wmincPref . '-code'] = array(
			'type' => 'text',
			'section' => 'personal/i18n',
			'label-message' => 'wminc-testwiki-code',
			'id' => $wmincPref . '-code',
			'maxlength' => (int)$wmincLangCodeLength,
			'size' => (int)$wmincLangCodeLength,
			'help-message' => 'wminc-prefinfo-code',
			'validation-callback' => array( 'IncubatorTest', 'validateCodePreference' ),
		);

		$wgDefaultUserOptions[$wmincPref . '-project'] = 'none';

		$preferences = wfArrayInsertAfter( $preferences, $prefinsert, 'language' );

		return true;
	}
 /**
  * Called after the personal URLs have been set up, before they are shown.
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/PersonalUrls
  *
  * @since 0.1
  *
  * @param array $personal_urls
  * @param Title $title
  *
  * @return true
  */
 public static function onPersonalUrls(array &$personal_urls, Title &$title)
 {
     if (EPSettings::get('enableTopLink')) {
         global $wgUser;
         // Find the watchlist item and replace it by the my contests link and itself.
         if ($wgUser->isLoggedIn() && $wgUser->getOption('ep_showtoplink')) {
             $url = SpecialPage::getTitleFor('MyCourses')->getLinkUrl();
             $myCourses = array('text' => wfMsg('ep-toplink'), 'href' => $url, 'active' => $url == $title->getLinkUrl());
             $insertUrls = array('mycourses' => $myCourses);
             $personal_urls = wfArrayInsertAfter($personal_urls, $insertUrls, 'preferences');
         }
     }
     return true;
 }
Пример #4
0
/**
 * Display link in toolbox
*/
function wfWatchersExtensionAfterToolbox( $tpl, $toolbox ) { # Checked for HTML and MySQL insertion attacks
	# Only when displaying non-talk pages
	if( !isset( $toolbox['whatlinkshere'] ) || $toolbox['whatlinkshere'] === false ) {
		return true;
	}

	$title = $tpl->getSkin()->getTitle();
	$nt = SpecialPage::getTitleFor( 'Watchers' );
	$res['watchers'] = array(
		'href' => $nt->getLocalURL( 'page=' . $title->getPrefixedDBkey() ),
		'msg' => 'watchers_link_title',
		'id' => 't-watchers',
	);

	$after = isset( $toolbox['recentchangeslinked'] ) ? 'recentchangeslinked' : 'whatlinkshere';
	$toolbox = wfArrayInsertAfter( $toolbox, $res, $after );

	return true;
}
Пример #5
0
 /**
  * Add a little pretty to the preferences user info section
  *
  * @param $user User
  * @param $preferences array
  * @return bool
  */
 static function onGetPreferences($user, &$preferences)
 {
     global $wgLang;
     if (!$user->isAllowed('centralauth-merge')) {
         // Not allowed to merge, don't display merge information
         return true;
     }
     // Possible states:
     // - account not merged at all
     // - global accounts exists, but this local account is unattached
     // - this local account is attached, but migration incomplete
     // - all local accounts are attached
     $global = CentralAuthUser::getInstance($user);
     if ($global->exists()) {
         if ($global->isAttached()) {
             // Local is attached...
             $attached = count($global->listAttached());
             $unattached = count($global->listUnattached());
             if ($unattached) {
                 // Migration incomplete
                 $message = '<strong>' . wfMsgExt('centralauth-prefs-migration', 'parseinline') . '</strong>' . '<br />' . wfMsgExt('centralauth-prefs-count-attached', array('parseinline'), $wgLang->formatNum($attached)) . '<br />' . wfMsgExt('centralauth-prefs-count-unattached', array('parseinline'), $wgLang->formatNum($unattached));
             } else {
                 // Migration complete
                 $message = '<strong>' . wfMsgExt('centralauth-prefs-complete', 'parseinline') . '</strong>' . '<br />' . wfMsgExt('centralauth-prefs-count-attached', array('parseinline'), $wgLang->formatNum($attached));
             }
         } else {
             // Account is in migration, but the local account is not attached
             $message = '<strong>' . wfMsgExt('centralauth-prefs-unattached', 'parseinline') . '</strong>' . '<br />' . wfMsgExt('centralauth-prefs-detail-unattached', 'parseinline');
         }
     } else {
         // Not migrated.
         $message = wfMsgExt('centralauth-prefs-not-managed', 'parseinline');
     }
     $manageLinks = array();
     $manageLinks[] = Linker::linkKnown(SpecialPage::getTitleFor('MergeAccount'), wfMsgExt('centralauth-prefs-manage', 'parseinline'));
     $manageLinks[] = Linker::linkKnown(SpecialPage::getTitleFor('CentralAuth', $user->getName()), wfMsgExt('centralauth-prefs-view', 'parseinline'));
     $manageLinkList = wfMsg('parentheses', $wgLang->pipeList($manageLinks));
     $prefInsert = array('globalaccountstatus' => array('section' => 'personal/info', 'label-message' => 'centralauth-prefs-status', 'type' => 'info', 'raw' => true, 'default' => "{$message}<br />{$manageLinkList}"));
     $after = array_key_exists('registrationdate', $preferences) ? 'registrationdate' : 'editcount';
     $preferences = wfArrayInsertAfter($preferences, $prefInsert, $after);
     return true;
 }
 protected function updateTo2(&$json)
 {
     if (isset($json['config'])) {
         $config = $json['config'];
         $json['config'] = [];
         if (isset($config['_prefix'])) {
             $json = wfArrayInsertAfter($json, ['config_prefix' => $config['_prefix']], 'config');
             unset($config['_prefix']);
         }
         foreach ($config as $name => $value) {
             if ($name[0] !== '@') {
                 $json['config'][$name] = ['value' => $value];
                 if (isset($value[ExtensionRegistry::MERGE_STRATEGY])) {
                     $json['config'][$name]['merge_strategy'] = $value[ExtensionRegistry::MERGE_STRATEGY];
                     unset($value[ExtensionRegistry::MERGE_STRATEGY]);
                 }
             }
         }
     }
 }
 /**
  * Generates the subheading with links
  * @param User $userObj User object for the target
  * @return string Appropriately-escaped HTML to be output literally
  */
 function getSubTitle($userObj)
 {
     $linkRenderer = $this->getLinkRenderer();
     if ($userObj->isAnon()) {
         $user = htmlspecialchars($userObj->getName());
     } else {
         $user = $linkRenderer->makeLink($userObj->getUserPage(), $userObj->getName());
     }
     $links = '';
     $nt = $userObj->getUserPage();
     $talk = $nt->getTalkPage();
     if ($talk) {
         $tools = SpecialContributions::getUserLinks($this, $userObj);
         # Link to contributions
         $insert['contribs'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Contributions', $nt->getDBkey()), $this->msg('sp-deletedcontributions-contribs')->text());
         // Swap out the deletedcontribs link for our contribs one
         $tools = wfArrayInsertAfter($tools, $insert, 'deletedcontribs');
         unset($tools['deletedcontribs']);
         $links = $this->getLanguage()->pipeList($tools);
         // Show a note if the user is blocked and display the last block log entry.
         $block = Block::newFromTarget($userObj, $userObj);
         if (!is_null($block) && $block->getType() != Block::TYPE_AUTO) {
             if ($block->getType() == Block::TYPE_RANGE) {
                 $nt = MWNamespace::getCanonicalName(NS_USER) . ':' . $block->getTarget();
             }
             // LogEventsList::showLogExtract() wants the first parameter by ref
             $out = $this->getOutput();
             LogEventsList::showLogExtract($out, 'block', $nt, '', ['lim' => 1, 'showIfEmpty' => false, 'msgKey' => ['sp-contributions-blocked-notice', $userObj->getName()], 'offset' => '']);
         }
     }
     return $this->msg('contribsub2')->rawParams($user, $links)->params($userObj->getName());
 }
Пример #8
0
 /**
  * (non-PHPdoc)
  * @see EPPager::getFieldNames()
  */
 public function getFieldNames()
 {
     $fields = parent::getFieldNames();
     //		if ( array_key_exists( 'mc_id', $this->conds ) && array_key_exists( 'org_id', $fields ) ) {
     //			unset( $fields['org_id'] );
     //		}
     $fields = wfArrayInsertAfter($fields, array('_status' => 'status'), 'students');
     return $fields;
 }
	/**
	 * Hook for user preferences
	 */
	public static function GetPreferences( $user, &$preferences ) {
		$msg = wfMsgForContentNoTrans( 'onlinestatus-levels' );
		$lines = explode( "\n", $msg );
		$radios = array();

		foreach( $lines as $line ){
			if( substr( $line, 0, 1 ) != '*' )
				continue;
			$lev = trim( $line, '* ' );
			$radios[wfMsg( 'onlinestatus-toggle-' . $lev )] = $lev;
		}

		$preferences['onlineonlogin'] =
			array(
				'type' => 'toggle',
				'section' => 'misc',
				'label-message' => 'onlinestatus-pref-onlineonlogin',
			);

		$preferences['offlineonlogout'] =
			array(
				'type' => 'toggle',
				'section' => 'misc',
				'label-message' => 'onlinestatus-pref-offlineonlogout',
			);

		$prefs = array(
			'online' => array(
				'type' => 'radio',
				'section' => 'personal/info',
				'options' => $radios,
				'label-message' => 'onlinestatus-toggles-desc',
			),
			'showonline' => array(
				'type' => 'check',
				'section' => 'personal/info',
				'label-message' => 'onlinestatus-toggles-show',
				'help-message' => 'onlinestatus-toggles-explain',
			)
		);

		$after = array_key_exists( 'registrationdate', $preferences ) ? 'registrationdate' : 'editcount';
		$preferences = wfArrayInsertAfter( $preferences, $prefs, $after );

		return true;
	}
Пример #10
0
 /**
  * Handler for PersonalUrls hook.
  * Add a "Notifications" item to the user toolbar ('personal URLs').
  * @see http://www.mediawiki.org/wiki/Manual:Hooks/PersonalUrls
  * @param &$personal_urls Array of URLs to append to.
  * @param &$title Title of page being visited.
  * @param SkinTemplate $sk
  * @return bool true in all cases
  */
 static function onPersonalUrls(&$personal_urls, &$title, $sk)
 {
     global $wgEchoNewMsgAlert;
     $user = $sk->getUser();
     if ($user->isAnon() || self::isEchoDisabled($user)) {
         return true;
     }
     // Add a "My notifications" item to personal URLs
     if ($user->getOption('echo-notify-show-link')) {
         $notificationCount = MWEchoNotifUser::newFromUser($user)->getNotificationCount();
         $text = EchoNotificationController::formatNotificationCount($notificationCount);
         $url = SpecialPage::getTitleFor('Notifications')->getLocalURL();
         if ($notificationCount == 0) {
             $linkClasses = array('mw-echo-notifications-badge');
         } else {
             $linkClasses = array('mw-echo-unread-notifications', 'mw-echo-notifications-badge');
         }
         $notificationsLink = array('href' => $url, 'text' => $text, 'active' => $url == $title->getLocalUrl(), 'class' => $linkClasses);
         $insertUrls = array('notifications' => $notificationsLink);
         $personal_urls = wfArrayInsertAfter($personal_urls, $insertUrls, 'userpage');
     }
     // If the user has new messages, display a talk page alert
     if ($wgEchoNewMsgAlert && $user->getOption('echo-show-alert') && $user->getNewtalk()) {
         $personal_urls['mytalk']['text'] = $sk->msg('echo-new-messages')->text();
         $personal_urls['mytalk']['class'] = array('mw-echo-alert');
         $sk->getOutput()->addModuleStyles('ext.echo.alert');
     }
     return true;
 }
Пример #11
0
 static function onPersonalUrls(&$personal_urls, &$title)
 {
     global $wgUser;
     if ($wgUser->isAnon()) {
         return true;
     }
     global $wgLiquidThreadsEnableNewMessages;
     if ($wgLiquidThreadsEnableNewMessages) {
         $newMessagesCount = NewMessages::newMessageCount($wgUser);
         // Add new messages link.
         $url = SpecialPage::getTitleFor('NewMessages')->getLocalURL();
         $msg = $newMessagesCount ? 'lqt-newmessages-n' : 'lqt_newmessages';
         $newMessagesLink = array('href' => $url, 'text' => wfMessage($msg)->numParams($newMessagesCount)->text(), 'active' => $newMessagesCount > 0);
         $insertUrls = array('newmessages' => $newMessagesLink);
         if (in_array('watchlist', array_keys($personal_urls))) {
             // User has viewmywatchlist permission
             $personal_urls = wfArrayInsertAfter($personal_urls, $insertUrls, 'watchlist');
         } else {
             $personal_urls = wfArrayInsertAfter($personal_urls, $insertUrls, 'preferences');
         }
     }
     return true;
 }
	/**
	 * Hook: SpecialSearchProfiles
	 */
	public static function searchProfile( array &$profiles ) {
		global $wgTranslateMessageNamespaces;
		$insert = array();
		$insert['translation'] = array(
			'message' => 'translate-searchprofile',
			'tooltip' => 'translate-searchprofile-tooltip',
			'namespaces' => $wgTranslateMessageNamespaces,
		);

		$profiles = wfArrayInsertAfter( $profiles, $insert, 'help' );
		return true;
	}
Пример #13
0
 static function onPersonalUrls(&$personal_urls, &$title)
 {
     global $wgUser, $wgLang;
     if ($wgUser->isAnon()) {
         return true;
     }
     $newMessagesCount = NewMessages::newMessageCount($wgUser);
     // Add new messages link.
     $url = SpecialPage::getTitleFor('NewMessages')->getLocalURL();
     $msg = $newMessagesCount ? 'lqt-newmessages-n' : 'lqt_newmessages';
     $newMessagesLink = array('href' => $url, 'text' => wfMsg($msg, $wgLang->formatNum($newMessagesCount)), 'active' => $newMessagesCount > 0);
     $insertUrls = array('newmessages' => $newMessagesLink);
     $personal_urls = wfArrayInsertAfter($personal_urls, $insertUrls, 'watchlist');
     return true;
 }
Пример #14
0
/**
* Checkboxes in preferences for watching pages a user blanks or unblanks
*/
function PureWikiDeletionGetPreferences($user, &$preferences)
{
    $prefs = array('watchblank' => array('type' => 'check', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'purewikideletion-pref-watchblank'), 'watchunblank' => array('type' => 'check', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'purewikideletion-pref-watchunblank'));
    $after = array_key_exists('watchcreations', $preferences) ? 'watchcreations' : 'watchdefault';
    $preferences = wfArrayInsertAfter($preferences, $prefs, $after);
    return true;
}