plugin:usersubscriptions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
plugin:usersubscriptions [2010-08-09 09:22] – [2009-11-30] 82.210.255.132 | plugin:usersubscriptions [2019-08-11 18:14] – a new download link Aleksandr | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== usersubscriptions | + | ====== usersubscriptions |
---- plugin ---- | ---- plugin ---- | ||
- | description: | + | description: |
author | author | ||
email : etienne.meleard@free.fr | email : etienne.meleard@free.fr | ||
Line 12: | Line 12: | ||
similar | similar | ||
tags : subscription listing syntax | tags : subscription listing syntax | ||
- | ---- | ||
- | ^ Download | [[http://dokuwiki.yent.eu/ | + | downloadurl: |
+ | bugtracker : | ||
+ | sourcerepo : | ||
+ | donationurl: | ||
+ | |||
+ | screenshot_img: | ||
+ | ---- | ||
===== Description ===== | ===== Description ===== | ||
- | The Syntax | + | The Syntax Plugin allows to display the subscription list of the current user. It can display list for a specific namespace, the current namespace or all namespaces. In addition, it provides a quick way to subscribe or unsubscribe. |
- | //2009-01-27 : Added ACL check for quick subscribe dropdown filling//\\ | + | * 2010-09-24: merged some patches (thx to " |
- | // | + | |
- | //2009-09-15 : added template for easy styling, fixed some bugs (img paths ...) and added regexp based item exclusion (for _template, sidebar ...)//\\ | + | * 2009-01-27: Added ACL check for quick subscribe dropdown filling |
+ | * 2009-01-26: inherited subscription display option added, recursive parent subscription check fixed | ||
- | //En, De, Pt, Es and Fr lang files included, translations are welcome ...//\\ | + | //En, De, Pt, Es and Fr lang files included, translations are welcome...// |
//**Many thanks to Thomas and Mark for the De lang file, to RC for Pt lang file and to Federico for Es lang file**// | //**Many thanks to Thomas and Mark for the De lang file, to RC for Pt lang file and to Federico for Es lang file**// | ||
Line 32: | Line 38: | ||
< | < | ||
- | * [ns] : base namespace, MUST BE PRESENT IF OTHER OPTIONS ARE USED\\ Can be either empty or . for targeting the current namespace, | + | * '' |
- | * [r[=[N]]] | + | * '' |
- | * [deletelink] | + | * '' |
- | * [quicksubscribe] | + | * '' |
- | * [displayinheritedsubscriptions] | + | * '' |
===== Download and Installation ===== | ===== Download and Installation ===== | ||
- | Download | + | Search |
- | * [[http://dokuwiki.yent.eu/ | + | * [[https://trello-attachments.s3.amazonaws.com/5af4815352fa15728c62aaae/ |
==== Translations ==== | ==== Translations ==== | ||
===== Screenshot ===== | ===== Screenshot ===== | ||
- | | ||
- | {{ http:// | + | Generated by putting ''< |
- | ===== Sources ===== | + | {{ https:// |
- | ==== syntax.php | + | ===== Discussion ===== |
- | <code php> | + | ==== 2009-05-01 ==== |
- | <?php | + | |
- | /** | + | |
- | * User Subscriptions Plugin: allows connected user to see which pages / namespaces he have subscribed to and to subscribe or unsubscribe in a quick way | + | |
- | * | + | |
- | * @license | + | |
- | * @author | + | |
- | * | + | |
- | | + | |
- | * 2009/01/26 : inherited subscription display option added, recursive parent subscription check fixed | + | |
- | * 2009/01/27 : Added ACL check for quick subscribe dropdown filling | + | |
- | */ | + | |
- | + | ||
- | if(!defined(' | + | |
- | if(!defined(' | + | |
- | require_once(DOKU_PLUGIN.' | + | |
- | + | ||
- | /** | + | |
- | * All DokuWiki plugins to extend the parser/ | + | |
- | * need to inherit from this class | + | |
- | */ | + | |
- | class syntax_plugin_usersubscriptions extends DokuWiki_Syntax_Plugin { | + | |
- | + | ||
- | /** | + | |
- | * return some info | + | |
- | */ | + | |
- | function getInfo(){ | + | |
- | return confToHash(dirname(__FILE__).'/ | + | |
- | } | + | |
- | + | ||
- | function getType(){ return ' | + | |
- | function getPType(){ return ' | + | |
- | function getSort(){ return 167; } | + | |
- | + | ||
- | /** | + | |
- | * Connect pattern to lexer | + | |
- | */ | + | |
- | function connectTo($mode){ | + | |
- | $this->Lexer-> | + | |
- | } | + | |
- | /** | ||
- | * Handle the match | ||
- | */ | ||
- | function handle($match, | ||
- | $match = strtolower(trim(substr($match, | ||
- | $options = preg_split('/ | ||
- | $recursive = false; | ||
- | $deletelink = false; | ||
- | $quicksubscribe = false; | ||
- | $displayinheritedsubscriptions = false; | ||
- | $ns = ''; | ||
- | if(count($options) > 0) { | ||
- | $ns = trim($options[0]); | ||
- | if(count($options) > 1) { | ||
- | $os = array_slice($options, | ||
- | $opts = array(); | ||
- | for($i=0; | ||
- | $o = explode(' | ||
- | $opts[$o[0]] = isset($o[1]) ? $o[1] : true;; | ||
- | } | ||
- | $recursive = isset($opts[' | ||
- | if(!is_numeric($recursive)) $recursive = -2; | ||
- | $deletelink = isset($opts[' | ||
- | $quicksubscribe = isset($opts[' | ||
- | $displayinheritedsubscriptions = isset($opts[' | ||
- | } | ||
- | } | ||
- | return array($ns, $recursive, $deletelink, | ||
- | } | ||
- | |||
- | /** | ||
- | * Create output | ||
- | */ | ||
- | function render($mode, | ||
- | global $INFO; | ||
- | if(($mode == ' | ||
- | global $ID; | ||
- | |||
- | $ns = $data[0]; | ||
- | $recursive = $data[1]; | ||
- | $deletelink = $data[2]; | ||
- | $quicksubscribe = $data[3]; | ||
- | $displayinheritedsubscriptions = $data[4]; | ||
- | |||
- | // prevent caching to ensure the subscriptions list is fresh | ||
- | $renderer-> | ||
- | |||
- | $status = ''; | ||
- | |||
- | // check if user requested a subscription deletion | ||
- | if($unsubscribe = $_REQUEST[' | ||
- | // user chooses to unsubscribe -> update mlist file | ||
- | list($type, | ||
- | if($type == ' | ||
- | $file = metaFN($id, ' | ||
- | }else{ | ||
- | if(!getNS($id)) { | ||
- | $file = metaFN(getNS($id), | ||
- | }else{ | ||
- | $file = metaFN(getNS($id), | ||
- | } | ||
- | } | ||
- | if(@file_exists($file)) { | ||
- | $status = io_deleteFromFile($file, | ||
- | } | ||
- | } | ||
- | |||
- | // check if user requested a new subscription | ||
- | if($subscribe = $_REQUEST[' | ||
- | if($subscribe != '' | ||
- | // user chooses to subscribe -> update mlist file | ||
- | list($type, | ||
- | if(auth_quickaclcheck($id) >= AUTH_READ) { | ||
- | if($type == ' | ||
- | $file = metaFN($id, ' | ||
- | $update = !is_subscribed($id, | ||
- | }else{ | ||
- | $file = metaFN($id, '/ | ||
- | $update = !is_subscribed($id.':', | ||
- | } | ||
- | if($update) { | ||
- | $status = io_saveFile($file, | ||
- | } | ||
- | } | ||
- | } | ||
- | } | ||
- | | ||
- | // output the list | ||
- | |||
- | if($ns == '' | ||
- | $nss = $this-> | ||
- | $ns = getNS($ID); | ||
- | }else if($ns == ' | ||
- | $nss = $this-> | ||
- | $ns = ''; | ||
- | }else $nss = $this-> | ||
- | |||
- | // get subscriptions | ||
- | $elements = array(); | ||
- | |||
- | $elements = $this-> | ||
- | ksort($elements); | ||
- | |||
- | $tius = false; | ||
- | $usersubscriptions = array(); | ||
- | foreach($elements as $id => $info) { | ||
- | $info[' | ||
- | |||
- | $info[' | ||
- | $info[' | ||
- | $id = preg_replace('/: | ||
- | $usersubscriptions[$id] = $info; | ||
- | } | ||
- | |||
- | if(file_exists(DOKU_TPLINC.' | ||
- | else include DOKU_PLUGIN.' | ||
- | |||
- | return true; | ||
- | } | ||
- | return false; | ||
- | } | ||
- | |||
- | function _getUserSubscriptions($ns, | ||
- | global $INFO; | ||
- | $us = array(); | ||
- | $exclude = array( | ||
- | ' | ||
- | ' | ||
- | ); | ||
- | $isns = !preg_match('/ | ||
- | foreach($exclude as $r) if(preg_match($r, | ||
- | if(auth_quickaclcheck($ns) < AUTH_READ) return $us; | ||
- | $cns = preg_replace('/ | ||
- | $s = is_subscribed($cns, | ||
- | $sns = is_subscribed($cns, | ||
- | $us[$cns] = array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ); | ||
- | if($ns == $cns) { | ||
- | foreach(new DirectoryIterator(preg_replace('/ | ||
- | if(!$item-> | ||
- | $scns = strtolower($cns.$item-> | ||
- | if($item-> | ||
- | $us = array_merge($us, | ||
- | } | ||
- | } | ||
- | } | ||
- | return $us; | ||
- | } | ||
- | } | ||
- | |||
- | ?> | ||
- | </ | ||
- | |||
- | ==== usersubscriptions.tpl.php ==== | ||
- | |||
- | <code php> | ||
- | <?php | ||
- | // DEFAULT TEMPLATE FOR THE USERSUBSCRIPTIONS PLUGIN | ||
- | // You can copy it to your current template directory to customize it | ||
- | |||
- | /* Useful variables and methods available in the template : | ||
- | * $deletelink (bool) : tells whether delete subscription link must be active | ||
- | * $nss (string) : contains the name of the base namespace specified in plugin parameters | ||
- | * $status (string) : contains nothing if no action was triggered, " | ||
- | * $this-> | ||
- | * $usersubscriptions (array) : contains the list of subscriptions to display, with ns path as id and fields : | ||
- | * usersubscribed (bool) : tells whether the user subscribed to the namespace (directly or inherited) | ||
- | * selfsubscribed (bool) : tells whether the user subscribed directly to the namespace | ||
- | * subscribedfromparent (bool) : tells whether the user subscribed to a parent namespace of the namespace | ||
- | * inheritedsubscription (bool) : tells whether the user only subscribed to a parent namespace of the namespace and not directly to it | ||
- | * itemdelete (bool) : tells whether the delete subscription link can be displayed | ||
- | * isnamespace (bool) : tells whether id refers to a page or a namespace | ||
- | * | ||
- | * $quicksubscribe (bool) : tells whether the quicksubscribe panel must be displayed | ||
- | */ | ||
- | ?> | ||
- | <a name=" | ||
- | <table class=" | ||
- | <tr> | ||
- | <th colspan="<? | ||
- | </ | ||
- | <?php if($status != '' | ||
- | <tr> | ||
- | <td colspan="<? | ||
- | </ | ||
- | <?php } | ||
- | foreach($usersubscriptions as $id => $info) { | ||
- | if(!$info[' | ||
- | ?> | ||
- | <tr> | ||
- | < | ||
- | <p class=" | ||
- | <a href="<? | ||
- | < | ||
- | </ | ||
- | < | ||
- | <a href="<? | ||
- | </ | ||
- | <br /> | ||
- | <? | ||
- | </ | ||
- | </ | ||
- | <td class=" | ||
- | <?php if($info[' | ||
- | <img src="<? | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | <?php | ||
- | } | ||
- | if(!count($usersubscriptions)) { | ||
- | ?> | ||
- | <tr> | ||
- | <td colspan="<? | ||
- | </ | ||
- | <?php | ||
- | } | ||
- | |||
- | if($quicksubscribe) { | ||
- | ?> | ||
- | <tr> | ||
- | <td colspan="<? | ||
- | <?php echo $this-> | ||
- | < | ||
- | < | ||
- | <?php | ||
- | foreach($usersubscriptions as $id => $info) { | ||
- | if($info[' | ||
- | ?> | ||
- | < | ||
- | < | ||
- | <? | ||
- | </ | ||
- | <?php | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | < | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | <?php | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | </ | ||
- | |||
- | ==== style.css ==== | ||
- | |||
- | <code css> | ||
- | div.dokuwiki table.usersubscriptions { | ||
- | position: relative; | ||
- | border: 1px solid __text_alt__; | ||
- | width: 75%; | ||
- | margin: 10px auto 15px auto; | ||
- | border-collapse: | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions th.usersubscriptions_namespace { | ||
- | text-align: | ||
- | padding: 3px; | ||
- | border-bottom: | ||
- | background: | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td.usersubscriptions_nothing { | ||
- | text-align: | ||
- | padding: 5px; | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td.usersubscription_success { | ||
- | font-style: | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td.usersubscription_failure { | ||
- | color: red; | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td.usersubscriptions_nothing select option.usersubscriptions_nsopt { | ||
- | font-weight: | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td.usersubscriptions_nothing select option.usersubscriptions_selopt { | ||
- | font-style: | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td p.usersubscriptions_description { | ||
- | font-style: | ||
- | margin: 1px 0 1px 10px; | ||
- | font-size: 90%; | ||
- | padding: 5px; | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td.usersubscriptions_delete img { | ||
- | vertical-align: | ||
- | margin: 5px; | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td p.usersubscriptions_description img { | ||
- | float: left; | ||
- | margin: 5px; | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td p.usersubscriptions_description span.usersubscriptions_id { | ||
- | font-style: | ||
- | font-weight: | ||
- | font-size: 130%; | ||
- | } | ||
- | |||
- | div.dokuwiki table.usersubscriptions td.usersubscriptions_delete { | ||
- | text-align: | ||
- | width: 50px; | ||
- | } | ||
- | </ | ||
- | |||
- | ===== Discussion ===== | ||
- | ==== 2009-05-01 ==== | ||
* " | * " | ||
* A similar problem exists for the URL of a background element in the style.css file. | * A similar problem exists for the URL of a background element in the style.css file. | ||
Line 551: | Line 195: | ||
--------------- | --------------- | ||
Did you add NOCACHE to the page? | Did you add NOCACHE to the page? | ||
+ | >no, I didn't - it works properly after including a < | ||
+ | |||
+ | ==== 2010-09-24 ==== | ||
+ | |||
+ | Included all patches, block now shows where it is expected to ... Also moved cache disabling line a bit upper, because when user disconnected, | ||
+ | |||
+ | ==== 2010-12-05 ==== | ||
+ | |||
+ | After an Dokuwiki-upgrade to the newest version (Anteater) i get an error, when i want to open the subscription-page. | ||
+ | "Fatal error: Call to undefined function is_subscribed() in / | ||
+ | Is there a new Plugin-Version on the horizon or can you help me? | ||
+ | |||
+ | > Indeed the is_subscribed() function has disappeared from Dokuwiki (it was used through an include inside the plugin). | ||
+ | > A quick " | ||
+ | > Below a copy of the code coming from the former release of Dokuwiki | ||
+ | function is_subscribed($id, | ||
+ | if(!$ns) { | ||
+ | $file=metaFN($id,' | ||
+ | } else { | ||
+ | if(!getNS($id)) { | ||
+ | $file = metaFN(getNS($id),' | ||
+ | } else { | ||
+ | $file = metaFN(getNS($id),'/ | ||
+ | } | ||
+ | } | ||
+ | if (@file_exists($file)) { | ||
+ | $mlist = file($file); | ||
+ | $pos = array_search($uid." | ||
+ | return is_int($pos); | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | | ||
+ | It should probably be more proper to work on a patch that will use the new Dokuwiki functions, but I don't have enough time at now. | ||
+ | > Hope this help, waiting for a better solution | ||
+ | > MR (2010-12-08) | ||
+ | |||
+ | **Thank you very much, it works fine now! thumbup** | ||
+ | |||
+ | |||
+ | ==== 2014-04-04 ==== | ||
+ | |||
+ | I have installed this plug in, yet now this appears | ||
+ | Fatal error: Call to undefined function is_subscribed() | ||
+ | in lib\plugins\usersubscriptions\syntax.php on line 178 | ||
+ | Can someone help me please? |
plugin/usersubscriptions.txt · Last modified: 2023-12-17 21:29 by Aleksandr