DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:ifauth

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:ifauth [2017-06-08 22:13] – [ifauth Plugin] 45.33.114.120plugin:ifauth [2022-01-08 13:08] (current) – [IfAuth Plugin] note highlighted Michaelsy
Line 1: Line 1:
-====== ifauth Plugin ======+====== IfAuth Plugin ======
  
 ---- plugin ---- ---- plugin ----
-description: Set portion of page to be displayed/hidden for authorized group+description: Set portion of page to be displayed/hidden for authorized group
 author     : Otto Vainio author     : Otto Vainio
 email      : otto@valjakko.net email      : otto@valjakko.net
 type       : Syntax type       : Syntax
 lastupdate : 2005-09-23 lastupdate : 2005-09-23
-compatible : Frusterick Manners, 2009-12-25c, Anteater, Rincewind, Binky, Ponder Stibbons, Hrun+compatible : Frusterick Manners, 2009-12-25c, Anteater, Rincewind, Binky, Ponder Stibbons, Hrun, Greebo, !Hogfather
 depends    : depends    :
 conflicts  : conflicts  :
-similar    : nodisp,condition+similar    : showif, condition, isauth, nodisp, ifauthex
 tags       : acl, groups, hide, if, users tags       : acl, groups, hide, if, users
  
 downloadurl: http://koti.mbnet.fi/oiv/pubtest/ifauth.zip downloadurl: http://koti.mbnet.fi/oiv/pubtest/ifauth.zip
 ---- ----
 +
 +^ :!: There is a new plugin [[plugin:ifauthex|ifauthex]] which is actively updated. You may want to use it instead :!:\\  --- [[user>oiv|oiv]] //2019-01-11 23:22// ^
  
 ===== Description ===== ===== Description =====
Line 20: Line 22:
 With this plugin you can set portion of page to be displayed/hidden for authorized user or group.  With this plugin you can set portion of page to be displayed/hidden for authorized user or group. 
  
-The text is still on the page, but not displayed. For true hiding, you would have to use the include plugin and set the appropritate ACLs.+The text is still on the page, but not displayed. For true hiding, you would have to use the nodisp or include plugin and set the appropriate ACLs.
  
 **Please note! The page is always set as not cached! So it will impact performance!** **Please note! The page is always set as not cached! So it will impact performance!**
Line 72: Line 74:
 > And what about hide text from not authorized group? Like: //<ifauth !@ALL>**OK**</ifauth>// > And what about hide text from not authorized group? Like: //<ifauth !@ALL>**OK**</ifauth>//
 > It will be useful...  > It will be useful... 
 +
 +>  Removal of <p> tags Needs to be fixed. Fix:
 +> <code php>
 +            // Remove '\n<p>\n' from start and '\n</p>\n' from the end.
 +
 +            if (stristr(substr($r,0,5),"\n<p>\n")) {
 +              $r = substr($r,5);
 +            }
 +
 +            if (stristr(substr($r,-7),"\n\n</p>\n")) {
 +              $r = substr($r,0,-7);
 +            }
 +            
 +            if (stristr(substr($r,-6),"\n</p>\n")) {
 +              $r = substr($r,0,-6);
 +
 +            $renderer->doc .= $r;
 +</code> --- Chris 2017-08-19
  
 ===== Installation ===== ===== Installation =====
  
-Using Plugin Manager from [[http://koti.mbnet.fi/oiv/pubtest/ifauth.zip|here]]+Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
-==== Plugin ====+==== Manually install ====
  
 Create a new folder ''lib/plugin/ifauth/'' and place the following file in it: ''syntax.php''. Create a new folder ''lib/plugin/ifauth/'' and place the following file in it: ''syntax.php''.
Line 109: Line 129:
         'author' => 'Otto Vainio',         'author' => 'Otto Vainio',
         'email'  => 'oiv-ifauth@valjakko.net',         'email'  => 'oiv-ifauth@valjakko.net',
-        'date'   => '2005-09-26',+        'date'   => '2005-09-23',
         'name'   => 'ifauth plugin',         'name'   => 'ifauth plugin',
         'desc'   => 'Show content at this time',         'desc'   => 'Show content at this time',
-        'url'    => 'http://www.dokuwiki.org/plugin:ifauth',+        'url'    => 'http://wiki.splitbrain.org/wiki:plugins',
       );       );
     }     }
Line 142: Line 162:
     }     }
     function connectTo($mode) {     function connectTo($mode) {
-      $this->Lexer->addEntryPattern('<ifauth.*?>(?=.*?</ifauth>)',$mode,'plugin_ifauth');+      $this->Lexer->addEntryPattern('<ifauth.*?>(?=.*?\x3C/ifauth\x3E)',$mode,'plugin_ifauth');
     }     }
     function postConnect() {     function postConnect() {
Line 152: Line 172:
     * Handle the match     * Handle the match
     */     */
-    function handle($match, $state, $pos, &$handler){+    function handle($match, $state, $pos, Doku_Handler $handler){
       switch ($state) {       switch ($state) {
         case DOKU_LEXER_ENTER :         case DOKU_LEXER_ENTER :
Line 171: Line 191:
     * Create output     * Create output
     */     */
-    function render($mode, &$renderer, $data) {+    function render($mode, Doku_Renderer $renderer, $data) {
  
 // ifauth stoes wanted user/group array // ifauth stoes wanted user/group array
Line 244: Line 264:
 </code> </code>
  
- + --- [[user>Juergen_aus_Zuendorf|Juergen_aus_Zuendorf]] //2018-02-06 17:44//\\ 
- +-> Changes for compatibility to PHP7:\\ 
 +"&$handler" and "&$renderer" to "Doku_Handler $handler" and "Doku_Renderer $renderer"
  
 ===== Discussion ===== ===== Discussion =====
  
 >This plugin messes up the Header levels causing them to nest/indent improperly. I've also come across situations where it caused the section edit buttons to be located improperly, and function improperly. Anyone know how to fix that? EDIT: the [[plugin:outdent]] plugin can help with the indenting problem (but not the section edit button problem). I suspect the plugin needs to be written to run BEFORE the rest of the syntax on the page is parsed. >This plugin messes up the Header levels causing them to nest/indent improperly. I've also come across situations where it caused the section edit buttons to be located improperly, and function improperly. Anyone know how to fix that? EDIT: the [[plugin:outdent]] plugin can help with the indenting problem (but not the section edit button problem). I suspect the plugin needs to be written to run BEFORE the rest of the syntax on the page is parsed.
 +
 +>>To avoid this I use the [[include]] plugin as workaround:
 +>>The part of the wiki page that should be hided has to be moved to another page and then be included by %%{{page>...}}%%. Then the section edit function can be used in the included page.
 +>> --- [[user>Juergen_aus_Zuendorf|Juergen_aus_Zuendorf]] //2018-10-30 13:13//
  
 >What's happen if someone show source of page ? do they see the hidden text ? >What's happen if someone show source of page ? do they see the hidden text ?
plugin/ifauth.1496952818.txt.gz · Last modified: 2017-06-08 22:13 by 45.33.114.120

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki