Hi,
Is there any way to display information in a wiki page only if a user is logged in.
The long story. On my main page, I'd like to have specific information displayed only if the user is logged in. I wonder if there is any way to use some "ParserFunctions" to check if we have a logged user or a guest.
{{ #if loggedUser .....
There is the isLoggedIn check that I could do from an extension, but I would rather prefer to not rely on extension
Thank
I have not found a 'process' (extension or base system function) that does what you are looking for. But ..
From the documentation found at http://svn.wikimedia.org/doc/
User::isLoggedIn ( )
A more legible check for non-anonymousness.
Returns true if the user is not an anonymous visitor.
Returns: bool
Definition at line 1716 of file User.php.
References getID().
Referenced by getBlockedStatus(), and isAnon().
This would be your best bet to be sure someone is logged in. With this you could write either a parser extension or a simple extension which could do the work needed.
DSig David Tod Sigafoos | SANMAR Corporation PICK Guy 206-770-5585 davesigafoos@sanmar.com
-----Original Message----- From: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] On Behalf Of Gaetan Lord Sent: Thursday, July 19, 2007 22:03 To: mediawiki-l@lists.wikimedia.org Subject: [Mediawiki-l] Selective information displayed for logged user
Hi,
Is there any way to display information in a wiki page only if a user is logged in.
The long story. On my main page, I'd like to have specific information displayed only if the user is logged in. I wonder if there is any way to use some "ParserFunctions" to check if we have a logged user or a guest.
{{ #if loggedUser .....
There is the isLoggedIn check that I could do from an extension, but I would rather prefer to not rely on extension
well, this is what I taught, it doesn't hurt to ask Thanks, you confirm my suspicion
On 7/20/07, Dave Sigafoos davesigafoos@sanmar.com wrote:
I have not found a 'process' (extension or base system function) that does what you are looking for. But ..
From the documentation found at http://svn.wikimedia.org/doc/
User::isLoggedIn ( )
A more legible check for non-anonymousness.
Returns true if the user is not an anonymous visitor.
Returns: bool
Definition at line 1716 of file User.php.
References getID().
Referenced by getBlockedStatus(), and isAnon().
This would be your best bet to be sure someone is logged in. With this you could write either a parser extension or a simple extension which could do the work needed.
DSig David Tod Sigafoos | SANMAR Corporation PICK Guy 206-770-5585 davesigafoos@sanmar.com
-----Original Message----- From: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] On Behalf Of Gaetan Lord Sent: Thursday, July 19, 2007 22:03 To: mediawiki-l@lists.wikimedia.org Subject: [Mediawiki-l] Selective information displayed for logged user
Hi,
Is there any way to display information in a wiki page only if a user is logged in.
The long story. On my main page, I'd like to have specific information displayed only if the user is logged in. I wonder if there is any way to use some "ParserFunctions" to check if we have a logged user or a guest.
{{ #if loggedUser .....
There is the isLoggedIn check that I could do from an extension, but I would rather prefer to not rely on extension
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
There's nothing like this. And, if you make an extension for this, you'll need to disable the parser cache (or modify it to take into account the logged/unlogged state). Else, only the state of last purge will be shown. Content on sidebars is not stored on the article cache, so it's a better place to put this kind of content (as the username does).
I came with the following, from my very limited php, and it does what I'm looking for. There is probably a simpler way, but why make things simple when we could make them complicated.
I create a basic extension named AmILogged.php (see below) I have the ParserFunctions extension installed
Then in my wiki page, I have the following
{{#if: {{#WhoAmI: }} |
Information specific to logged user only
}}
This is my basic extension
<?php
$wgExtensionCredits['specialpage'][] = array( 'name' => 'AmILogged.php', 'author' =>'Gaetan Lord', 'description' => 'Return if the user is logged or anonymous' );
# Define a setup function $wgExtensionFunctions[] = 'wfAmILogged_Setup';
# Add a hook to initialise the magic word $wgHooks['LanguageGetMagic'][] = 'wfAmILogged_Magic';
function wfAmILogged_Setup() { global $wgParser; $wgParser->setFunctionHook( 'AmILogged', 'wfAmILogged_Render' ); }
function wfAmILogged_Magic( &$magicWords, $langCode ) { $magicWords['AmILogged'] = array( 0, 'AmILogged' ); return true; }
function wfAmILogged_Render( &$parser ) { $parser->disableCache(); global $wgUser; if ($wgUser->isLoggedIn()) { return "1"; } else { return ""; }
}
?>
On 7/20/07, Platonides Platonides@gmail.com wrote:
There's nothing like this. And, if you make an extension for this, you'll need to disable the parser cache (or modify it to take into account the logged/unlogged state). Else, only the state of last purge will be shown. Content on sidebars is not stored on the article cache, so it's a better place to put this kind of content (as the username does).
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
On 20/07/07, Gaetan Lord mediawiki@gaetanlord.ca wrote:
function wfAmILogged_Render( &$parser ) { $parser->disableCache(); global $wgUser; if ($wgUser->isLoggedIn()) { return "1"; } else { return ""; }
You can avoid disabling the parser cache for this if you hook User::getPageRenderingHash() and append login state information. There should be an example of doing this in our Subversion repository.
Rob Church
This goes way beyond my limited php expertise. I look at the ParserCache.php code to understand, but I'm not sure if I do. Maybe I do not look at the right location.
Will there be a major benefit to not disable the cache. I do not expect more than a couple hundreds hit per day on the site , and this will only be use for the main page. Most people will have a direct link to other wiki page. Those have dynamic content and people will look at them to gather the data they're looking for.
Thank
On 7/20/07, Rob Church robchur@gmail.com wrote:
On 20/07/07, Gaetan Lord mediawiki@gaetanlord.ca wrote:
function wfAmILogged_Render( &$parser ) { $parser->disableCache(); global $wgUser; if ($wgUser->isLoggedIn()) { return "1"; } else { return ""; }
You can avoid disabling the parser cache for this if you hook User::getPageRenderingHash() and append login state information. There should be an example of doing this in our Subversion repository.
Rob Church
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Depending on the kind of information, you could display it somewhere outside the page itself - like in the sidebar or footer.
On Jul 20, 2007, at 12:03 AM, Gaetan Lord wrote:
Hi,
Is there any way to display information in a wiki page only if a user is logged in.
The long story. On my main page, I'd like to have specific information displayed only if the user is logged in. I wonder if there is any way to use some "ParserFunctions" to check if we have a logged user or a guest.
{{ #if loggedUser .....
There is the isLoggedIn check that I could do from an extension, but I would rather prefer to not rely on extension
Thank
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054
mediawiki-l@lists.wikimedia.org