Last modified: 2013-03-13 11:03:02 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T32046, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30046 - Adding possibility to get a different sidebar for logged in and not logged in users
Adding possibility to get a different sidebar for logged in and not logged in...
Status: NEW
Product: MediaWiki
Classification: Unclassified
Interface (Other open bugs)
1.21.x
All All
: Lowest enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-07-25 09:56 UTC by Paolo Benvenuto
Modified: 2013-03-13 11:03 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Paolo Benvenuto 2011-07-25 09:56:29 UTC
It would be useful, and yet very simple to implement to add the option that the sidebar is different for logged in and not logged in users.

According to the idea in http://www.mediawiki.org/wiki/Manual:Interface/Sidebar#Change_sidebar_content_when_logged_in_.28PHP.29 the following changes suffice:

- add two system variables (maybe better names are to be found)
-- $wgTwoSidebars with default value false; if set to true shows a different sidebar for users not logged in
-- $wgAlternateSidebar for the name of the sidebar for users not logged in, which defaults to Anon_sidebar or other better name
- in includes/Skin.php, function buildSidebar():
-- at the beginning, add "global $wgUser, $wgTwoSidebars, $wgAlternateSidebar";
-- change the line "$this->addToSidebar( $bar, 'sidebar' );" into:

if ($wgUser->isLoggedIn() && $wgTwoSidebars) $this->addToSidebar( $bar, 'sidebar' );
else $this->addToSidebar( $bar, $wgAlternateSidebar );

I personally tested this solution in my wiki and it works.

Hoping it could be implemented in mediawiki code.
Comment 1 Daniel Friesen 2011-10-12 05:26:39 UTC
This functionality is actually not as easy as you describe it. That code change you describe does not take into account that the addToSidebar line is in the middle of caching code. If the sidebar cache is enabled, you can actually end up with a logged out sidebar showing to logged in users, or a logged in sidebar showing to logged out users, because that's what happens to be in the cache.

I've been considering this in my skin rewrite plans. However I still haven't been shown an example where having two sidebar versions is a valid case, that isn't actually part of a hack to work around something that should actually be fixed instead of adding this hack.

Tbh, I almost want to WONTFIX this until someone actually gives a valid example of why one would want two separate sidebars.
Comment 2 Paolo Benvenuto 2011-10-12 05:49:52 UTC
The user case is that of a wiki where unregistered users aren't allowed to edit pages: unregistered users are readers while registered users are editor.

In that case unregistered users are to be given a "reader's sidebar", with links which are appropriated to their tasks.

Registered users, on the contrary, are to be given different links in order to do their work.

About the caching, my wiki implements the double sidebar as described in the description. I'm experimenting on it, with two browser, one logged in and the other not logged it. My wiki uses memcached caching. In LocalSettings I have:

$wgMainCacheType = CACHE_MEMCACHED;
$wgParserCacheType = CACHE_MEMCACHED; # optional
$wgMessageCacheType = CACHE_MEMCACHED; # optional
$wgMemCachedServers = array (
  0 => '127.0.0.1:11211',
);
$wgSessionsInMemcached = true; # optional

Loading the same page at the same time with the two browsers shows the correct (logged in or not logged in) sidebar. I.e.: apparently the caching doesn't apply to the sidebar.
Comment 3 Paolo Benvenuto 2011-10-12 07:21:19 UTC
CORRECTING MY PREVIOUS COMMENT.

I hadn't understood clearly, you were referring to sidebar caching, while I meant article caching.

I think things can be done at least in the case when $wgEnableSidebarCache isn't set, with the code:

if ($wgEnableSidebarCache || $wgUser->isLoggedIn() && $wgTwoSidebars) $this->addToSidebar( $bar, 'sidebar' );
else $this->addToSidebar( $bar, $wgAlternateSidebar );

This code treats 'sidebar' (default) as the sidebar for logged in user; perhaps it's better to consider default sidebar that for not logged in user and $wgLoggedInSidebarName the sidebar name for logged in users.

This way the code would become:

if (! $wgUser->isLoggedIn() || $wgEnableSidebarCache || ! $wgTwoSidebars) $this->addToSidebar( $bar, 'sidebar' );
else $this->addToSidebar( $bar, $wgLoggedInSidebarName );
Comment 4 Paolo Benvenuto 2012-07-08 14:06:02 UTC
Daniel, have you thought anything about this enhancement?
Comment 5 Daniel Friesen 2012-07-08 15:35:40 UTC
(In reply to comment #4)
> Daniel, have you thought anything about this enhancement?

I'm still not entirely sold on this idea of the logged in sidebar being different. editor == user is actually a false assumption.
Comment 6 Platonides 2012-07-08 15:50:24 UTC
Instead of a $wgTwoSidebars I'd make it something like MediaWiki:anonsidebarwhich if non-empty overrides MediaWiki:sidebar (or both MediaWiki:sidebar-anon and MediaWiki:sidebar-user)
Similar to how we have both MediaWiki:sitenotice and MediaWiki:anonnotice
Comment 7 Paolo Benvenuto 2012-07-08 15:59:32 UTC
MediaWiki:anonsidebarwhich looks like a pretty solution!!!
Comment 8 Daniel Friesen 2012-07-08 18:07:01 UTC
Just to make it clear. Even if someone came up with a good rationale for this I wasn't planning on coding something like anonsidebar or a $wg.

My end goal is to rewrite this whole sidebar system and ditch this bad way of configuring things. If anon/user links were to be used it would be done in part of a UI with a toggle.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links