summaryrefslogtreecommitdiff
path: root/inc/infoutils.php
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-04-01 16:55:40 +0100
committerChristopher Smith <chris@jalakai.co.uk>2013-04-01 16:55:40 +0100
commitd3bae4781025502fdfb729854e39f8b2072b8a37 (patch)
tree49412e48ab52f56744870f85d255b41709a74a43 /inc/infoutils.php
parente71b0ef705b86bb653fcae43e6845acbe6fd7fd2 (diff)
downloadrpg-d3bae4781025502fdfb729854e39f8b2072b8a37.tar.gz
rpg-d3bae4781025502fdfb729854e39f8b2072b8a37.tar.bz2
add capability to restrict recipients of dokuwiki 'msg' alerts. This is useful where message is added to the queue before authentication is initialized
Diffstat (limited to 'inc/infoutils.php')
-rw-r--r--inc/infoutils.php37
1 files changed, 35 insertions, 2 deletions
diff --git a/inc/infoutils.php b/inc/infoutils.php
index 92607e4fa..3d1326624 100644
--- a/inc/infoutils.php
+++ b/inc/infoutils.php
@@ -269,7 +269,13 @@ function check(){
* @author Andreas Gohr <andi@splitbrain.org>
* @see html_msgarea
*/
-function msg($message,$lvl=0,$line='',$file=''){
+
+define('MSG_PUBLIC', 0);
+define('MSG_USERS_ONLY', 1);
+define('MSG_MANAGERS_ONLY',2);
+define('MSG_ADMINS_ONLY',4);
+
+function msg($message,$lvl=0,$line='',$file='',$show=MSG_PUBLIC){
global $MSG, $MSG_shown;
$errors[-1] = 'error';
$errors[0] = 'info';
@@ -279,7 +285,7 @@ function msg($message,$lvl=0,$line='',$file=''){
if($line || $file) $message.=' ['.utf8_basename($file).':'.$line.']';
if(!isset($MSG)) $MSG = array();
- $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message);
+ $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message, 'show' => $show);
if(isset($MSG_shown) || headers_sent()){
if(function_exists('html_msgarea')){
html_msgarea();
@@ -290,6 +296,33 @@ function msg($message,$lvl=0,$line='',$file=''){
}
}
+function info_msg_canshow($msg){
+ global $INFO, $auth;
+
+ // is the message public? - everyone and anyone can see it
+ if (empty($msg['show'])) return true;
+
+ // restricted msg, but no authentication
+ if (empty($auth)) return false;
+
+ switch ($msg['show']){
+ case MSG_USERS_ONLY:
+ return !empty($INFO['userinfo']);
+
+ case MSG_MANAGERS_ONLY:
+ return $INFO['ismanager'];
+
+ case MSG_ADMINS_ONLY:
+ return $INFO['isadmin'];
+
+ default:
+ trigger_error('invalid msg show restriction. msg="'.$msg['msg'].'" show='.$msg['show'].'"', E_USER_WARNING);
+ return $INFO['isadmin'];
+ }
+
+ return false;
+}
+
/**
* print debug messages
*