webgui/lib/WebGUI/Macro/AdminToggle.pm
2003-01-05 18:32:19 +00:00

46 lines
1.6 KiB
Perl

package WebGUI::Macro::AdminToggle;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Session;
use WebGUI::URL;
#-------------------------------------------------------------------
sub _replacement {
my ($temp, @param, $turnOn, $turnOff);
if (WebGUI::Privilege::isInGroup(4)) {
@param = WebGUI::Macro::getParams($_[0]);
if ($session{var}{adminOn}) {
$turnOff = $param[1] || WebGUI::International::get(517);
$temp = '<a href="'.WebGUI::URL::page('op=switchOffAdmin').'">'.$turnOff.'</a>';
} else {
$turnOn = $param[0] || WebGUI::International::get(516);
$temp = '<a href="'.WebGUI::URL::page('op=switchOnAdmin').'">'.$turnOn.'</a>';
}
}
return $temp;
}
#-------------------------------------------------------------------
sub process {
my ($output, $temp);
$output = $_[0];
$output =~ s/\^AdminToggle\((.*?)\)\;/_replacement($1)/ge;
$output =~ s/\^AdminToggle\;/_replacement()/ge;
return $output;
}
1;