Enhanced existing extension to conditionally show content based on user group membership.
[lhc/web/wiklou.git] / extensions / ConditionalShowSection / README
1 /*
2 * ConditionalShowSection MediaWiki extension
3 *
4 * @author Jean-Lou Dupont
5 * @package MediaWiki
6 * @subpackage Extensions
7 * @licence GNU General Public Licence 2.0
8 * This extension enables to conditionally show/hide a section
9 * of wikitext that appears between the <cshow> </cshow> tags.
10 *
11 * Add to LocalSettings.php
12 * with: require_once("extensions/ConditionalShowSection/ConditionalShowSection.php");
13 *
14 * HISTORY:
15 * 1.1: corrected bug when "ingroup" option not present, wrong results.
16 * 1.2: used "recursiveTagParse" to get cleaner parsing.
17 * 1.3: corrected error with default initialisation of userReqLogged
18 * 1.4: changed to using 'getEffectiveGroups' in order to have also access
19 * to the implicit '*' group and the default group for logged users 'user'.
20 * 1.5: Allow to check multiple groups - separated by ","
21 */
22
23
24
25 {{Extension|templatemode =
26 |name = ConditionalShow
27 |status = stable
28 |type1 = tag
29 |type2 = user rights
30 |type3 = mywiki
31 |hook1 = ParserFirstCallInit
32 |hook2 =
33 |username = [[user:jldupont]]
34 |author =
35 |description = Conditionally show a wikitext section based on user group rights
36 |image =
37 |imagesize =
38 |version = 1.5
39 |update = 2009-09-10
40 |mediawiki = tested on 1.8.2, 1.9.3, 1.10, 1.14, 1.15, 1.16A
41 |php =
42 |license = GNU General Public Licence 2.0
43 |download = [http://wiki.jldupont.com/Extension:ConditionalContent http version <1.5]
44 |readme =
45 |changelog =
46 |parameters =
47 |tags = <cshow>,</cshow>
48 |rights =
49 |example =
50 |compatibility =
51 }}
52
53 ==What can this extension do?==
54 This extension implementes the <nowiki><cshow></nowiki> tag which conditionally shows wikitext within the tags based on user group rights and certain other parameters.
55
56 Using the tags should be to make the user experience less confusing or more useful by only showing information relevant to the user and specific groups that user belongs to.
57 <div style="width: 80%; margin-left: auto; margin-right: auto; padding: 4px; border: 2px solid #FF0000; background-color: #FFDDDD; text-align: center;">
58 '''PLEASE NOTE!!!'''
59
60 This tag does not protect information or instructions from being disclosed to the reader.
61
62 The user can still see the information by editing the page or even by "view source". If you are looking to actually protect information, this is '''NOT''' the extension you want to use!
63
64 This extension only helps you selectively show content or navigation based on groups the user belongs to.
65 </div>
66 ==Note==
67
68 This extension is not 'cache' friendly; if one requires this feature, then [[Extension:BizzWiki|BizzWiki platform]] provides a solution through [[Extension:ParserPhase2|Parser Phase 2 extension]].
69
70 ==Usage==
71
72 Like other tags, this can be used two ways - by using the tag itself within wikitext, or by using the tag function within templates.
73
74 If you are using it within normal wikitext, the <nowiki><cshow>. . .</cshow></nowiki> syntax suffices. If you are using it within a template, you will need to use the parser tag function as illustrated [[#Example within a Template | below]].
75
76 ===Example in Wikitext===
77 By default, the section of wikitext within the tags is HIDDEN unless the conditions are met - in this case the user must be logged in and belong the group 'sysops'
78
79 <pre>
80 <cshow logged=1 ingroup='sysop'> This text will appear if a user with membership to 'sysop' group views this page</cshow>
81 </pre>
82
83 ===Example within a Template===
84
85 If you are using this within a template or as part of a template, you need to use the <nowiki>{{##tag: . . .}}</nowiki> syntax.
86
87 <pre>
88 {{#tag:cshow |
89 This text will appear if a user with membership to 'sysop' group views this page
90 | logged=1 ingroup='sysop'
91 }}
92 </pre>
93
94 ==Arguments==
95
96 By default, the tagged section is HIDDEN unless the following conditions are met:
97 * Argument: logged = '1' or '0'
98 * Argument: ingroup = 'group XYZ' (Note, as of version 1.5, you can list multiple groups, e.g. 'sysop,approved'
99
100 If no arguments are provided for:
101 logged --> assume 'don't care'
102 innGroup --> assume '' (no group)
103
104 In other words, if no 'ingroup' parameter is given, then the condition 'ingroup' is never met.
105
106 If no "logged" parameter is given, then this condition is always met.
107
108 ==Download instructions==
109
110 The current version is available from SVN.
111
112 Source Code and additional information can also be found at [http://bluecortex.com/index.php?title=Bluecortex:ConditionalShow].
113 The code should be loaded to:
114
115 <code>$IP/extensions/ConditionalShowSection/ConditionalShowSection.php</code>. ''Note: [[Manual:$IP|$IP]] stands for the root directory of your MediaWiki installation, the same directory that holds [[Manual:LocalSettings.php|LocalSettings.php]]''.
116
117 ==Installation==
118 To install this extension, add the following to [[Manual:LocalSettings.php|LocalSettings.php]]:
119 <source lang="php">
120 require_once("$IP/extensions/ConditionalShowSection/ConditionalShowSection.php");
121 </source>
122
123 == Other Options ==
124 * [[Extension:ConditionalContent]]
125
126 [[Category:View page extensions]]