WebGUI 0.9.0 release
This commit is contained in:
commit
c57a922892
51 changed files with 7351 additions and 0 deletions
650
lib/WebGUI/Config.pm
Normal file
650
lib/WebGUI/Config.pm
Normal file
|
|
@ -0,0 +1,650 @@
|
|||
package WebGUI::Config;
|
||||
# This package was originally Data::Config
|
||||
|
||||
use strict;
|
||||
use Carp;
|
||||
use FileHandle;
|
||||
|
||||
use vars qw($CLASS $VERSION);
|
||||
$CLASS = 'WebGUI::Config';
|
||||
$VERSION = '0.8.3';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Data::Config - Module that can read easy-to-use configuration files
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Lets say you have a file F<mail.conf>
|
||||
|
||||
name = John Doe
|
||||
email = doe@somewhere.net
|
||||
server = mail.somewhere.net
|
||||
signature = -
|
||||
John Doe
|
||||
--
|
||||
Visit my homepage at http://www.somewhere.net/~doe/
|
||||
.
|
||||
|
||||
You can read it using the following program:
|
||||
|
||||
use Data::Source;
|
||||
my $mailconf = new Data::Source 'mail.conf';
|
||||
|
||||
and you can for example print the signature:
|
||||
|
||||
print $mailconf->param('signature');
|
||||
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module has been writen in order to provide an easy way to read
|
||||
simple configuration files. The format of these configuration files is
|
||||
itself extremely easy to understand, so that it can be used even by
|
||||
non-tech people (I hope!).
|
||||
|
||||
One of the reason I wrote this module is that I wanted a very easy way
|
||||
to feed data to HTML::Template-based scripts. Therefore, the API of
|
||||
Data::Config is compatible with HTML::Template, and you can write
|
||||
programs as simple as:
|
||||
|
||||
use strict;
|
||||
use Data::Config;
|
||||
use HTML::template;
|
||||
|
||||
my $source = new Data::Config 'file.src';
|
||||
my $tmpl = new HTML::Template type => 'filename',
|
||||
source => 'file.tmpl', associate => $source;
|
||||
print $tmpl->output;
|
||||
|
||||
=head2 Syntax
|
||||
|
||||
The syntax of the configuration files is pretty simple. To affect a
|
||||
value to a parameter, just write:
|
||||
|
||||
param = value of param
|
||||
|
||||
The parameter C<param> will have the value "value of param".
|
||||
You can also give multi-lines values this way:
|
||||
|
||||
text = -
|
||||
Perl is a language optimized for scanning arbitrary text files,
|
||||
extracting information from those text files, and printing
|
||||
reports based on that information. It's also a good language
|
||||
for many system management tasks. The language is intended to
|
||||
be practical (easy to use, efficient, complete) rather than
|
||||
beautiful (tiny, elegant, minimal).
|
||||
|
||||
[from perl(1)]
|
||||
.
|
||||
|
||||
Think of this as a "Unix-inspired" syntax. Instead of giving the value,
|
||||
you write '-' to mean "the value will follow" (in Unix, this means the
|
||||
data will come from standard input). To end the multi-lines value, you
|
||||
simply put a single dot '.' on a line (as in Unix mail, but it needn't
|
||||
be on the first column).
|
||||
|
||||
If you need to write several identical records, you can use lists.
|
||||
The syntax is:
|
||||
|
||||
list_name {
|
||||
# affectations
|
||||
}
|
||||
|
||||
Example: a version history
|
||||
|
||||
## that's the version history of Data::Config :)
|
||||
|
||||
history {
|
||||
date = 2000.10.10
|
||||
vers = 0.7.0
|
||||
text = First fully functional release.
|
||||
}
|
||||
|
||||
history {
|
||||
date = 2000.11.04
|
||||
vers = 0.7.1
|
||||
text = -
|
||||
Minor change in the internal structure: options
|
||||
are now grouped.
|
||||
.
|
||||
}
|
||||
|
||||
history {
|
||||
date = 2000.11.05
|
||||
vers = 0.8.0
|
||||
text = -
|
||||
Code cleanup (mainly auto-generation of the
|
||||
options accessors).
|
||||
Added list support.
|
||||
.
|
||||
}
|
||||
|
||||
Note that currently, there must be only one item on each line.
|
||||
This means you can't write:
|
||||
|
||||
line { param = value }
|
||||
|
||||
but instead
|
||||
|
||||
line {
|
||||
param = value
|
||||
}
|
||||
|
||||
I think that's not a big deal.
|
||||
|
||||
Also note that you can't nest lists.
|
||||
|
||||
You can put some comments in your file. If a line begins with a
|
||||
sharp sign '#', it will be ignored.
|
||||
|
||||
=head2 Objects Options
|
||||
|
||||
If the default symbols used in the configuration file syntax doesn't
|
||||
fit your needs, you can change them using the following methods.
|
||||
|
||||
=over 4
|
||||
|
||||
=item affectation_symbol
|
||||
|
||||
Use this method to change the affectation symbol. Default is '='.
|
||||
|
||||
=item multiline_begin_symbol
|
||||
|
||||
Use this method to change the multiline begin symbol. Default is '-'.
|
||||
|
||||
=item multiline_end_symbol
|
||||
|
||||
Use this method to change the multiline end symbol. Default is '.'.
|
||||
|
||||
=item comment_line_symbol
|
||||
|
||||
Use this method to change the comment symbol. Default is '#'.
|
||||
|
||||
=item list_begin_symbol
|
||||
|
||||
Use this method to change the list begin symbol. Default is '{'.
|
||||
|
||||
=item list_end_symbol
|
||||
|
||||
Use this method to change the list end symbol. Default is '}'.
|
||||
|
||||
=item case_sensitive
|
||||
|
||||
Use this method to change the case behaviour. Defaults is 1 (case sensitive).
|
||||
|
||||
=back
|
||||
|
||||
=head2 Methods
|
||||
|
||||
=over 8
|
||||
|
||||
=item new
|
||||
|
||||
This method creates a new object. You can give an optional parameter, in
|
||||
which case the C<read_source()> method is called with that parameter.
|
||||
|
||||
=item read_source ( FILENAME )
|
||||
|
||||
=item read_source ( FILEHANDLE )
|
||||
|
||||
This method reads the content of the given file and stores the parameters
|
||||
values in the object. The argument can be either a filename or a filehandle.
|
||||
This is useful if you want to store your parameters in your program:
|
||||
|
||||
use Data::Source;
|
||||
my $conf = new Data::Source \*DATA;
|
||||
|
||||
$conf->param(-debug => 1); ## set debug on
|
||||
|
||||
if($conf->param('debug')) {
|
||||
print "current options:\n";
|
||||
print $conf->dump_param(-prefix => ' ');
|
||||
}
|
||||
|
||||
# ...
|
||||
|
||||
__END__
|
||||
## default values
|
||||
verbose = 1
|
||||
debug = 0
|
||||
die_on_errors = 0
|
||||
|
||||
Note that you can call the C<read_source()> method several times if you want
|
||||
to merge the settings from differents configuration files.
|
||||
|
||||
=item param
|
||||
|
||||
This is the general purpose manipulating method. It can used to get or set
|
||||
the value of the parameters of an object.
|
||||
|
||||
1) Return a list of the parameters:
|
||||
|
||||
@params = $conf->param;
|
||||
|
||||
2) Return the value of a parameter:
|
||||
|
||||
print $conf->param('debug');
|
||||
|
||||
3) Return the values of a number of parameters:
|
||||
|
||||
@dbg = $conf->param(qw(debug verbose));
|
||||
|
||||
4) Set the value of a parameter:
|
||||
|
||||
## using CGI.pm-like syntax
|
||||
$conf->param(-debug => 0);
|
||||
|
||||
## using a hashref
|
||||
$conf->param({ debug => 0 });
|
||||
|
||||
5) Set the values of a number of parameters
|
||||
|
||||
## using CGI.pm-like syntax
|
||||
$conf->param(
|
||||
-warn_non_existant => 1,
|
||||
-mangle => 0
|
||||
);
|
||||
|
||||
## using a hashref
|
||||
$conf->param(
|
||||
{
|
||||
warn_non_existant => 1,
|
||||
mangle => 0
|
||||
}
|
||||
);
|
||||
|
||||
=item all_parameters
|
||||
|
||||
This method returns the list of the parameters of an object.
|
||||
|
||||
=item delete ( LIST )
|
||||
|
||||
This method deletes the given parameters.
|
||||
|
||||
=item delete_all
|
||||
|
||||
This method deletes all the parameters.
|
||||
|
||||
=item clear
|
||||
|
||||
This method sets the given parameters to undef.
|
||||
|
||||
=item clear_params
|
||||
|
||||
This method sets all the parameters to undef.
|
||||
|
||||
=item dump_param ( OPTIONS )
|
||||
|
||||
This method returns a dump of the parameters as a string. It can be used
|
||||
to simply print them out, or to save them to a configuration file.
|
||||
|
||||
B<Options>
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
prefix - If you set this option to a string, it will be printed before printing
|
||||
|
||||
each parameter.
|
||||
|
||||
=item *
|
||||
|
||||
suffix - If you set this option to a string, it will be printed after printing
|
||||
each parameter.
|
||||
|
||||
=back
|
||||
|
||||
=back
|
||||
|
||||
=head1 VERSION HISTORY
|
||||
|
||||
=over 4
|
||||
|
||||
=item v0.8.3, Thursday, November 15, 2000
|
||||
|
||||
Added the method C<clear()>.
|
||||
|
||||
=item v0.8.2, Saturday, November 11, 2000
|
||||
|
||||
Added a destructor method. This was needed because of a strange behaviour
|
||||
in MacPerl 5.2.0r4.
|
||||
|
||||
=item v0.8.1, Thursday, November 8, 2000
|
||||
|
||||
Minor bug corrected: empty or undefined parameters are not added.
|
||||
|
||||
Bug corrected: syntaxic symbol are now escaped through quotemeta().
|
||||
|
||||
=item v0.8.0, Sunday, November 5, 2000
|
||||
|
||||
Code cleanup (mainly auto-generation of the options accessors).
|
||||
|
||||
Added list support.
|
||||
|
||||
=item v0.7.1, Saturday, November 4, 2000
|
||||
|
||||
Minor change in the internal structure: options are now grouped.
|
||||
|
||||
=item v0.7.0, Tuesday, October 10, 2000
|
||||
|
||||
First fully functional release.
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
SE<eacute>bastien Aperghis-Tramoni <madingue@resus.univ-mrs.fr>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Data::Config is Copyright (C)2000 SE<eacute>bastien Aperghis-Tramoni.
|
||||
|
||||
This program is free software. You can redistribute it and/or modify it
|
||||
under the terms of either the Perl Artistic License or the GNU General
|
||||
Public License, version 2 or later.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
my @base = (
|
||||
options => {
|
||||
comment_line_symbol => '#',
|
||||
affectation_symbol => '=',
|
||||
multiline_begin_symbol => '-',
|
||||
multiline_end_symbol => '.',
|
||||
list_begin_symbol => '{',
|
||||
list_end_symbol => '}',
|
||||
case_sensitive => 1
|
||||
},
|
||||
state => { },
|
||||
param => { }
|
||||
);
|
||||
|
||||
## set the accessors for the object options
|
||||
for my $option (keys %{$base[1]}) {
|
||||
eval qq| sub $option { _get_set_option(shift, '$option', shift) } |;
|
||||
warn "[$CLASS] Initialisation error: $@ " if $@;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# new()
|
||||
# ---
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $self = bless { @base }, $class;
|
||||
$self->read_source(shift) if @_;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# DESTROY()
|
||||
# -------
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
$self->clear_params;
|
||||
$self->delete_all;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# _get_set_option()
|
||||
# ---------------
|
||||
sub _get_set_option {
|
||||
my $self = shift;
|
||||
my $option = shift;
|
||||
my $value = shift;
|
||||
|
||||
carp "[$CLASS] Uknown option '$option' " unless exists $self->{options}{$option};
|
||||
|
||||
if(defined $value) {
|
||||
($value, $self->{options}{$option}) = ($self->{options}{$option}, $value);
|
||||
return $value
|
||||
} else {
|
||||
return $self->{options}{$option}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# read_source()
|
||||
# -----------
|
||||
sub read_source {
|
||||
my $self = shift;
|
||||
my $fh = _file_or_handle(shift);
|
||||
my $aff_sym = $self->affectation_symbol;
|
||||
my $multiline = $self->multiline_begin_symbol;
|
||||
my $multi_end = $self->multiline_end_symbol;
|
||||
my $list = $self->list_begin_symbol;
|
||||
my $list_end = $self->list_end_symbol;
|
||||
local $_;
|
||||
|
||||
while(defined($_ = <$fh>)) {
|
||||
next if /^\s*$/; ## skip empty lines
|
||||
next if /^\s*#/; ## skip comments
|
||||
chomp;
|
||||
|
||||
if(/^\s*(\w+)\s*\Q${list}\E$/) {
|
||||
$self->{state}{current_list} = $1;
|
||||
$self->{state}{current_stack} = [];
|
||||
next
|
||||
}
|
||||
|
||||
if(/^\s*\Q${list_end}\E\s*$/) {
|
||||
push @{$self->{'param'}{$self->{state}{current_list}}}, { @{$self->{state}{current_stack}} };
|
||||
$self->{state}{current_list} = 0;
|
||||
$self->{state}{current_stack} = [];
|
||||
next
|
||||
}
|
||||
|
||||
my($field,$value) = (/^\s*(\w+)\s*\Q${aff_sym}\E\s*(.*)$/);
|
||||
|
||||
if($value =~ /^\s*${multiline}\s*$/) {
|
||||
$value = '';
|
||||
$_ = <$fh>;
|
||||
|
||||
while(not /^\s*\Q${multi_end}\E\s*$/) {
|
||||
$value .= $_;
|
||||
$_ = <$fh>;
|
||||
}
|
||||
}
|
||||
|
||||
$self->param({ $field => $value });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# _file_or_handle()
|
||||
# ---------------
|
||||
sub _file_or_handle {
|
||||
my $file = shift;
|
||||
|
||||
if(not ref $file) {
|
||||
my $fh = new FileHandle $file;
|
||||
croak "[$CLASS] Can't open file '$file': $! " unless defined $fh;
|
||||
return $fh
|
||||
}
|
||||
|
||||
return $file
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# param()
|
||||
# -----
|
||||
sub param {
|
||||
my $self = shift;
|
||||
return $self->all_parameters unless @_;
|
||||
|
||||
my $args = _parse_args(@_);
|
||||
|
||||
my @retlist = (); ## return list
|
||||
|
||||
## get the value of the desired parameters
|
||||
for my $arg (@{$args->{'get'}}) {
|
||||
carp("[$CLASS] Parameter '$arg' does not exist ") and next
|
||||
if not exists $self->{'param'}{_case_($self, $arg)};
|
||||
|
||||
push @retlist, $self->{'param'}{_case_($self, $arg)}
|
||||
}
|
||||
|
||||
## set the names parameters to new values
|
||||
my $current_list = $self->{'state'}{current_list};
|
||||
my @arg_list = keys %{$args->{'set'}};
|
||||
|
||||
if($current_list) {
|
||||
unless(exists $self->{'param'}{$current_list}) {
|
||||
$self->{'param'}{$current_list} = []
|
||||
}
|
||||
|
||||
for my $arg (@arg_list) {
|
||||
push @{$self->{'state'}{'current_stack'}}, _case_($self, $arg) => $args->{'set'}{$arg}
|
||||
}
|
||||
|
||||
} else {
|
||||
for my $arg (@arg_list) {
|
||||
$self->{'param'}{_case_($self, $arg)} = $args->{'set'}{$arg}
|
||||
}
|
||||
}
|
||||
|
||||
return wantarray ? @retlist : $retlist[0]
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# _case_()
|
||||
# ------
|
||||
sub _case_ {
|
||||
my $self = shift;
|
||||
my $param = shift;
|
||||
return ($self->case_sensitive ? $param : lc $param)
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# _parse_args()
|
||||
# -----------
|
||||
sub _parse_args {
|
||||
my %args = ( get => [], set => {} );
|
||||
|
||||
while(my $arg = shift) {
|
||||
if(my $ref_type = ref $arg) {
|
||||
|
||||
## setting multiples parameters using a hashref
|
||||
if($ref_type eq 'HASH') {
|
||||
local $_;
|
||||
for (keys %$arg) {
|
||||
$args{'set'}{$_} = $arg->{$_} if $_
|
||||
}
|
||||
|
||||
} else {
|
||||
carp "[$CLASS] Bad ref $ref_type; ignoring it ";
|
||||
next
|
||||
}
|
||||
|
||||
} else {
|
||||
## setting a parameter to a new value
|
||||
if(substr($arg, 0, 1) eq '-') {
|
||||
$arg = substr($arg, 1);
|
||||
my $val = shift;
|
||||
carp("[$CLASS] Undefined value for parameter '$arg' ") and next
|
||||
if not defined $val;
|
||||
$args{'set'}{$arg} = $val if $arg
|
||||
|
||||
## getting the value of a parameter
|
||||
} else {
|
||||
push @{$args{'get'}}, $arg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return \%args
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# all_parameters()
|
||||
# --------------
|
||||
sub all_parameters {
|
||||
my $self = shift;
|
||||
return keys %{$self->{'param'}}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# delete()
|
||||
# ------
|
||||
sub delete {
|
||||
my $self = shift;
|
||||
|
||||
for my $param (@_) {
|
||||
carp("[$CLASS] Parameter '$param' does not exist ") and next
|
||||
if not exists $self->{'param'}{_case_($self, $param)};
|
||||
delete $self->{'param'}{_case_($self, $param)}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# delete_all()
|
||||
# ----------
|
||||
sub delete_all {
|
||||
my $self = shift;
|
||||
$self->delete($self->all_parameters)
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# clear()
|
||||
# -----
|
||||
sub clear {
|
||||
my $self = shift;
|
||||
for my $param (@_) {
|
||||
$self->param({$param => ''})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# clear_params()
|
||||
# ------------
|
||||
sub clear_params {
|
||||
my $self = shift;
|
||||
for my $param ($self->all_parameters) {
|
||||
$self->param({$param => ''})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# dump_param()
|
||||
# ----------
|
||||
sub dump_param {
|
||||
my $self = shift;
|
||||
my $args = _parse_args(@_);
|
||||
my $prefix = $args->{'set'}{'prefix'} || '';
|
||||
my $suffix = $args->{'set'}{'suffix'} || '';
|
||||
my $str = '';
|
||||
|
||||
for my $param (sort $self->all_parameters) {
|
||||
next unless $param;
|
||||
## multi-line value ?
|
||||
my $multiline = 1 if $self->param($param) =~ /\n|\r/;
|
||||
|
||||
$str .= join '', $prefix, $param, ' ', $self->affectation_symbol, ' ',
|
||||
($multiline ? $self->multiline_begin_symbol . $/ : ''),
|
||||
$self->param($param),
|
||||
($multiline ? $self->multiline_end_symbol . $/ : ''),
|
||||
$suffix, $/;
|
||||
}
|
||||
|
||||
return $str
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
35
lib/WebGUI/ErrorHandler.pm
Normal file
35
lib/WebGUI/ErrorHandler.pm
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package ErrorHandler;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#sub fatalError {
|
||||
# my ($key);
|
||||
# print httpHeader();
|
||||
# print "<h1>WebGUI Fatal Error</h1>Something unexpected happened that caused this system to fault. Please send t
|
||||
his message to ";#.$session{setting}{adminEmail}."<p>";
|
||||
# print $0." at ".localtime(time)." reported:<br>";
|
||||
# print $_[0];
|
||||
# print "<p><h3>Caller</h3><table border=1><tr><td valign=top>";
|
||||
# print "<b>Level 1</b><br>".join("<br>",caller(1));
|
||||
# print "</td><td valign=top>"."<b>Level 2</b><br>".join("<br>",caller(2));
|
||||
# print "</td><td valign=top>"."<b>Level 3</b><br>".join("<br>",caller(3));
|
||||
# print "</td><td valign=top>"."<b>Level 4</b><br>".join("<br>",caller(4));
|
||||
# print "</td></tr></table><p><h3>Form Variables</h3>";
|
||||
# #foreach $key (keys %session(form}) {
|
||||
# # print $key." = ".$session{form}{$key}."<br>";
|
||||
# #}
|
||||
# exit;
|
||||
#}
|
||||
|
||||
|
||||
|
||||
157
lib/WebGUI/Form.pm
Normal file
157
lib/WebGUI/Form.pm
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
package WebGUI::Form;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 qw(vars subs);
|
||||
use WebGUI::Session;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _fixQuotes {
|
||||
my $value = shift;
|
||||
$value =~ s/\"/\"\;/g;
|
||||
return $value;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub checkbox {
|
||||
my ($output, $name, $value, $checked);
|
||||
($name, $value, $checked) = @_;
|
||||
if ($checked) {
|
||||
$checked = ' checked';
|
||||
}
|
||||
$output = '<input type="checkbox" name="'.$name.'" value="'.$value.'"'.$checked.'>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub file {
|
||||
my ($output, $name);
|
||||
($name) = @_;
|
||||
$output = '<input type="file" name="'.$name.'">';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub hidden {
|
||||
my ($output, $name, $value);
|
||||
($name, $value) = @_;
|
||||
$value = _fixQuotes($value);
|
||||
$output = '<input type="hidden" name="'.$name.'" value="'.$value.'">';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub password {
|
||||
my ($output, $name, $size, $maxLength, $value);
|
||||
$name = shift;
|
||||
$size = shift;
|
||||
if ($size eq "") {
|
||||
$size = 15;
|
||||
}
|
||||
$maxLength = shift;
|
||||
if ($maxLength ne "") {
|
||||
$maxLength = ' maxlength="'.$maxLength.'"';
|
||||
}
|
||||
$value = shift;
|
||||
$output = '<input type="password" name="'.$name.'" value="'.$value.'" size="'.$size.'" '.$maxLength.'>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub radio {
|
||||
my ($output, $name, $value, $checked);
|
||||
($name, $value, $checked) = @_;
|
||||
if ($checked) {
|
||||
$checked = ' checked';
|
||||
}
|
||||
$output = '<input type="radio" name="'.$name.'" value="'.$value.'"'.$checked.'>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# eg: selectList(name, valueListHashref, selectedArrayref, size, multipleSelection, onChange)
|
||||
sub selectList {
|
||||
my ($output, $valueList, $key, $item, $name, $selected, $size, $multiple, $onChange);
|
||||
($name, $valueList, $selected, $size, $multiple, $onChange) = @_;
|
||||
if ($size > 1) {
|
||||
$size = ' size="'.$size.'"';
|
||||
}
|
||||
if ($multiple > 0) {
|
||||
$multiple = ' multiple="1"';
|
||||
}
|
||||
if ($onChange ne "") {
|
||||
$onChange = ' onChange="'.$onChange.'"';
|
||||
}
|
||||
$output = '<select name="'.$name.'"'.$size.$multiple.$onChange.'>';
|
||||
foreach $key (keys %{$valueList}) {
|
||||
$output .= '<option value="'.$key.'"';
|
||||
foreach $item (@$selected) {
|
||||
if ($item eq $key) {
|
||||
$output .= " selected";
|
||||
}
|
||||
}
|
||||
$output .= '>'.${$valueList}{$key};
|
||||
}
|
||||
$output .= '</select>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub submit {
|
||||
my ($output, $name, $value);
|
||||
$value = shift;
|
||||
$name = shift;
|
||||
$value = _fixQuotes($value);
|
||||
$output = '<input type="submit" name="'.$name.'" value="'.$value.'">';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub text {
|
||||
my ($output, $assistance, $name, $size, $maxLength, $value);
|
||||
($name, $size, $maxLength, $value, $assistance) = @_;
|
||||
if ($size eq "") {
|
||||
$size = 15;
|
||||
}
|
||||
if ($maxLength ne "") {
|
||||
$maxLength = ' maxlength="'.$maxLength.'"';
|
||||
}
|
||||
if ($assistance == 1) {
|
||||
$assistance = '<input type="button" style="font-size: 8pt;" onClick="window.dateField = this.form.'.$name.';calendar = window.open(\''.$session{setting}{lib}.'/calendar.html\',\'cal\',\'WIDTH=200,HEIGHT=250\');return false" value="set date">';
|
||||
}
|
||||
$value = _fixQuotes($value);
|
||||
$output = '<input type="text" name="'.$name.'" value="'.$value.'" size="'.$size.'" '.$maxLength.'>'.$assistance;
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub textArea {
|
||||
my ($output, $name, $value, $cols, $rows, $htmlEdit, $wrap);
|
||||
($name, $value, $cols, $rows, $htmlEdit, $wrap) = @_;
|
||||
if ($cols eq "") {
|
||||
$cols = 50;
|
||||
}
|
||||
if ($rows eq "") {
|
||||
$rows = 5;
|
||||
}
|
||||
if ($htmlEdit > 0) {
|
||||
$output = '<input type="button" onClick="colorText(this.form.'.$name.')" value="color" style="font-size: 8pt;"><input type="button" onClick="boldText(this.form.'.$name.')" value="bold" style="font-size: 8pt;"><input type="button" onClick="italicText(this.form.'.$name.')" value="italics" style="font-size: 8pt;"><input type="button" onClick="centerText(this.form.'.$name.')" value="center" style="font-size: 8pt;"><input type="button" onClick="list(this.form.'.$name.')" value="list" style="font-size: 8pt;"><input type="button" onClick="url(this.form.'.$name.')" value="link" style="font-size: 8pt;"><input type="button" onClick="email(this.form.'.$name.')" value="email" style="font-size: 8pt;"><input type="button" onClick="image(this.form.'.$name.')" value="image" style="font-size: 8pt;"><input type="button" onClick="showMe(this.form.'.$name.')" value="show me" style="font-size: 8pt;"><input type="button" onClick="copyright(this.form.'.$name.')" value="(C)" style="font-size: 8pt;"><input type="button" onClick="registered(this.form.'.$name.')" value="(R)" style="font-size: 8pt;"><input type="button" onClick="trademark(this.form.'.$name.')" value="TM" style="font-size: 8pt;"><br>';
|
||||
}
|
||||
if ($wrap eq "") {
|
||||
$wrap = "virtual";
|
||||
}
|
||||
$output .= '<textarea name="'.$name.'" cols="'.$cols.'" rows="'.$rows.'" wrap="'.$wrap.'">'.$value.'</textarea>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
173
lib/WebGUI/Macro.pm
Normal file
173
lib/WebGUI/Macro.pm
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
package WebGUI::Macro;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _recurseCrumbTrail {
|
||||
my ($sth, %data, $output);
|
||||
%data = WebGUI::SQL->quickHash("select pageId,parentId,title,urlizedTitle from page where pageId=$_[0]",$session{dbh});
|
||||
if ($data{pageId} > 1) {
|
||||
$output .= _recurseCrumbTrail($data{parentId});
|
||||
}
|
||||
if ($data{title} ne "") {
|
||||
$output .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data{urlizedTitle}.'">'.$data{title}.'</a> > ';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($output, $temp, @data, $sth, $first);
|
||||
$output = $_[0];
|
||||
#---carrot ^---
|
||||
if ($output =~ /\^\^/) {
|
||||
$output =~ s/\^\^/\^/g;
|
||||
}
|
||||
#---page url---
|
||||
if ($output =~ /\^\//) {
|
||||
$output =~ s/\^\//\$session{env}{SCRIPT_NAME}/g;
|
||||
}
|
||||
#---username---
|
||||
if ($output =~ /\^\@/) {
|
||||
$output =~ s/\^\@/$session{user}{username}/g;
|
||||
}
|
||||
#---uid---
|
||||
if ($output =~ /\^\#/) {
|
||||
$output =~ s/\^\#/$session{page}{userId}/g;
|
||||
}
|
||||
#---random number---
|
||||
if ($output =~ /\^\*/) {
|
||||
$temp = rand()*1000000000;
|
||||
$output =~ s/\^\*/$temp/g;
|
||||
}
|
||||
#---account link---
|
||||
if ($output =~ /\^a/) {
|
||||
$temp = '<a href="'.$session{page}{url}.'?op=displayAccount">My Account</a>';
|
||||
$output =~ s/\^a/$temp/g;
|
||||
}
|
||||
#---company name---
|
||||
if ($output =~ /\^c/) {
|
||||
$output =~ s/\^c/$session{setting}{companyName}/g;
|
||||
}
|
||||
#---crumb trail---
|
||||
if ($output =~ /\^C/) {
|
||||
$temp = '<span class="crumbTrail">'._recurseCrumbTrail($session{page}{parentId}).$session{page}{title}.'</span>';
|
||||
$output =~ s/\^C/$temp/g;
|
||||
}
|
||||
#---date---
|
||||
if ($output =~ /\^D/) {
|
||||
$temp = localtime(time);
|
||||
$output =~ s/\^D/$temp/g;
|
||||
}
|
||||
#---company email---
|
||||
if ($output =~ /\^e/) {
|
||||
$output =~ s/\^e/$session{setting}{companyEmail}/g;
|
||||
}
|
||||
#---home link---
|
||||
if ($output =~ /\^H/) {
|
||||
$temp = '<a href="'.$session{env}{SCRIPT_NAME}.'/home">Home</a>';
|
||||
$output =~ s/\^H/$temp/g;
|
||||
}
|
||||
#---login box---
|
||||
if ($output =~ /\^L/) {
|
||||
$temp = '<div class="loginBox">';
|
||||
if ($session{var}{sessionId}) {
|
||||
$temp .= 'Hello '.$session{user}{username}.'. Click <a href="'.$session{page}{url}.'?op=logout">here</a> to log out.';
|
||||
} else {
|
||||
$temp .= '<form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$temp .= WebGUI::Form::hidden("op","login").'<span class="formSubtext">Username:<br></span>';
|
||||
$temp .= WebGUI::Form::text("username",12,30).'<span class="formSubtext"><br>Password:<br></span>';
|
||||
$temp .= WebGUI::Form::password("identifier",12,30).'<span class="formSubtext"><br></span>';
|
||||
$temp .= WebGUI::Form::submit("login");
|
||||
$temp .= '</form>';
|
||||
}
|
||||
$temp .= '</div>';
|
||||
$output =~ s/\^L/$temp/g;
|
||||
}
|
||||
#---current menu vertical---
|
||||
if ($output =~ /\^M/) {
|
||||
$temp = '<span class="verticalMenu">';
|
||||
$sth = WebGUI::SQL->read("select title,urlizedTitle,pageId from page where parentId=$session{page}{pageId}",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
if (WebGUI::Privilege::canViewPage($data[2])) {
|
||||
$temp .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[1].'">'.$data[0].'</a><br>';
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
$temp .= '</span>';
|
||||
$output =~ s/\^M/$temp/g;
|
||||
}
|
||||
#---current menu horizontal ---
|
||||
if ($output =~ /\^m/) {
|
||||
$temp = '<span class="horizontalMenu">';
|
||||
$first = 1;
|
||||
$sth = WebGUI::SQL->read("select title,urlizedTitle,pageId from page where parentId=$session{page}{pageId}",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
if (WebGUI::Privilege::canViewPage($data[2])) {
|
||||
if ($first) {
|
||||
$first = 0;
|
||||
} else {
|
||||
$temp .= " · ";
|
||||
}
|
||||
$temp .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[1].'">'.$data[0].'</a>';
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
$temp .= '</span>';
|
||||
$output =~ s/\^m/$temp/g;
|
||||
}
|
||||
#---top menu vertical---
|
||||
if ($output =~ /\^T/) {
|
||||
$temp = '<span class="verticalMenu">';
|
||||
$sth = WebGUI::SQL->read("select title,urlizedTitle,pageId from page where parentId=1",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
if (WebGUI::Privilege::canViewPage($data[2])) {
|
||||
$temp .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[1].'">'.$data[0].'</a><br>';
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
$temp .= '</span>';
|
||||
$output =~ s/\^T/$temp/g;
|
||||
}
|
||||
#---top menu horizontal---
|
||||
if ($output =~ /\^t/) {
|
||||
$temp = '<span class="horizontalMenu">';
|
||||
$first = 1;
|
||||
$sth = WebGUI::SQL->read("select title,urlizedTitle,pageId from page where parentId=1",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
if (WebGUI::Privilege::canViewPage($data[2])) {
|
||||
if ($first) {
|
||||
$first = 0;
|
||||
} else {
|
||||
$temp .= " · ";
|
||||
}
|
||||
$temp .= '<a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[1].'">'.$data[0].'</a>';
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
$temp .= '</span>';
|
||||
$output =~ s/\^t/$temp/g;
|
||||
}
|
||||
#---company URL---
|
||||
if ($output =~ /\^u/) {
|
||||
$output =~ s/\^u/$session{setting}{companyURL}/g;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
40
lib/WebGUI/Mail.pm
Normal file
40
lib/WebGUI/Mail.pm
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package WebGUI::Mail;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Session;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#eg: send("jt@jt.com","hi, how are you","this is my message","bob@bob.com");
|
||||
sub send {
|
||||
my ($smtp);
|
||||
$smtp = Net::SMTP->new($session{setting}{smtpServer}); # connect to an SMTP server
|
||||
$smtp->mail($session{setting}{companyEmail}); # use the sender's address here
|
||||
$smtp->to($_[0]); # recipient's address
|
||||
$smtp->data(); # Start the mail
|
||||
# Send the header.
|
||||
$smtp->datasend("To: ".$_[0]."\n");
|
||||
$smtp->datasend("From: $session{setting}{companyName} <$session{setting}{companyEmail}>\n");
|
||||
$smtp->datasend("CC: $_[3]\n") if ($cc);
|
||||
$smtp->datasend("Subject: ".$_[1]."\n");
|
||||
$smtp->datasend("\n");
|
||||
# Send the body.
|
||||
$smtp->datasend($_[2]);
|
||||
$smtp->datasend("\n\n $session{setting}{companyName}\n $setting{setting}{companyEmail}\n $session{setting}{companyURL}\n");
|
||||
$smtp->dataend(); # Finish sending the mail
|
||||
$smtp->quit; # Close the SMTP connection
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
24
lib/WebGUI/Operation.pm
Normal file
24
lib/WebGUI/Operation.pm
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package WebGUI::Operation;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Operation::Account;
|
||||
use WebGUI::Operation::Admin;
|
||||
use WebGUI::Operation::Group;
|
||||
use WebGUI::Operation::Help;
|
||||
use WebGUI::Operation::Settings;
|
||||
use WebGUI::Operation::Style;
|
||||
use WebGUI::Operation::Page;
|
||||
use WebGUI::Operation::User;
|
||||
|
||||
|
||||
1;
|
||||
268
lib/WebGUI/Operation/Account.pm
Normal file
268
lib/WebGUI/Operation/Account.pm
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
package WebGUI::Operation::Account;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Digest::MD5 qw(md5_base64);
|
||||
use Exporter;
|
||||
use strict;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_createAccount &www_deactivateAccount &www_deactivateAccountConfirm &www_displayAccount &www_displayLogin &www_login &www_logout &www_recoverPassword &www_recoverPasswordFinish &www_saveAccount &www_updateAccount);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _hasBadPassword {
|
||||
if ($_[0] ne $_[1] || $_[0] eq "") {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _hasBadUsername {
|
||||
my ($otherUser);
|
||||
($otherUser) = WebGUI::SQL->quickArray("select username from user where lcase(username)=lcase('$_[0]')",$session{dbh});
|
||||
if ($otherUser ne "" || $_[0] eq "") {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _login {
|
||||
my ($cookieInfo);
|
||||
$cookieInfo = $_[0]."|".crypt($_[1],"yJ");
|
||||
WebGUI::Session::end($cookieInfo); #clearing out old session info just in case something bad happened
|
||||
if (WebGUI::Session::start($cookieInfo)) {
|
||||
WebGUI::Session::setCookie("wgSession",$cookieInfo);
|
||||
return "";
|
||||
} else {
|
||||
return "<b>Error:</b> Unable to initialize session vars because your session signature does not match your account information.<p>";
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_createAccount {
|
||||
my ($output);
|
||||
if ($session{user}{userId} != 1) {
|
||||
$output .= www_displayAccount();
|
||||
} else {
|
||||
$output .= ' <h1>Create Account</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","saveAccount");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Username</td><td>'.WebGUI::Form::text("username",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Password</td><td>'.WebGUI::Form::password("identifier1",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Password (confirm)</td><td>'.WebGUI::Form::password("identifier2",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Email Address</td><td>'.WebGUI::Form::text("email",20,255).'<span class="formSubtext"><br>This is only necessary if you wish to use features that require Email.</span></td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top"><a href="http://www.icq.com">ICQ</a> UIN</td><td>'.WebGUI::Form::text("icq",20,30).'<span class="formSubtext"><br>This is only necessary if you wish to use features that require ICQ.</span></td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("create").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
$output .= '<div class="accountOptions"><ul><li><a href="'.$session{page}{url}.'?op=displayLogin">I already have an account.</a><li><a href="'.$session{page}{url}.'?op=recoverPassword">I forgot my password.</a></ul></div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deactivateAccount {
|
||||
my ($output);
|
||||
if ($session{user}{userId} == 1) {
|
||||
$output .= www_displayLogin();
|
||||
} else {
|
||||
$output .= '<h1>Please Confirm</h1>';
|
||||
$output .= 'Are you certain you want to deactivate your account. If you proceed your account information will be lost permanently.<p>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deactivateAccountConfirm">Yes, I\'m sure.</a>';
|
||||
$output .= ' <a href="'.$session{page}{url}.'">No, I made a mistake.</a></div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deactivateAccountConfirm {
|
||||
if ($session{user}{userId} != 1) {
|
||||
WebGUI::SQL->write("delete from user where userId=$session{user}{userId}",$session{dbh});
|
||||
WebGUI::SQL->write("delete from groupings where userId=$session{user}{userId}",$session{dbh});
|
||||
WebGUI::Session::end($session{var}{sessionId});
|
||||
_login(1,"null");
|
||||
}
|
||||
return www_displayLogin();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_displayAccount {
|
||||
my ($output);
|
||||
if ($session{user}{userId} != 1) {
|
||||
$output .= ' <h1>Update Account Information</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","updateAccount");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">username</td><td>'.WebGUI::Form::text("username",20,30,$session{user}{username}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">password</td><td>'.WebGUI::Form::password("identifier1",20,30,"password").'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">password (confirm)</td><td>'.WebGUI::Form::password("identifier2",20,30,"password").'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">email address</td><td>'.WebGUI::Form::text("email",20,255,$session{user}{email}).'<span class="formSubtext"><br>This is only necessary if you wish to use features that require Email.</span></td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top"><a href="http://www.icq.com">ICQ</a> UIN</td><td>'.WebGUI::Form::text("icq",20,30,$session{user}{icq}).'<span class="formSubtext"><br>This is only necessary if you wish to use features that require ICQ.</span></td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("update").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
$output .= '<div class="accountOptions"><ul>';
|
||||
if (WebGUI::Privilege::isInGroup(3) || WebGUI::Privilege::isInGroup(4)) {
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=switchOnAdmin">Turn admin on.</a>';
|
||||
}
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=logout">Logout.</a><li><a href="'.$session{page}{url}.'?op=deactivateAccount">Please deactivate my account permanently.</a></ul></div>';
|
||||
} else {
|
||||
$output .= 'You need to be logged in to view your account information.<p>';
|
||||
$output .= www_displayLogin();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_displayLogin {
|
||||
my ($output);
|
||||
if ($session{var}{sessionId}) {
|
||||
$output .= www_displayAccount();
|
||||
} else {
|
||||
$output .= ' <h1>Login</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","login");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">username</td><td>'.WebGUI::Form::text("username",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">password</td><td>'.WebGUI::Form::password("identifier",20,30).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("login").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form>';
|
||||
$output .= '<div class="accountOptions"><ul><li><a href="'.$session{page}{url}.'?op=createAccount">Create a new account.</a><li><a href="'.$session{page}{url}.'?op=recoverPassword">I forgot my password.</a></ul></div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_login {
|
||||
my ($uid,$pass);
|
||||
($uid,$pass) = WebGUI::SQL->quickArray("select userId,identifier from user where username=".quote($session{form}{username}),$session{dbh});
|
||||
if (Digest::MD5::md5_base64($session{form}{identifier}) eq $pass && $session{form}{identifier} ne "") {
|
||||
_login($uid,$pass);
|
||||
return "";
|
||||
} else {
|
||||
return "<h1>Invalid Account</h1>The account information you supplied is invalid. Either the account does not exist or the username/password combination was incorrect.".www_displayLogin();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_logout {
|
||||
WebGUI::Session::end($session{var}{sessionId});
|
||||
#_login(1,"null");
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_recoverPassword {
|
||||
my ($output);
|
||||
if ($session{var}{sessionId}) {
|
||||
$output .= www_displayAccount();
|
||||
} else {
|
||||
$output .= ' <h1>Recover Password</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","recoverPasswordFinish");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Email Address</td><td>'.WebGUI::Form::text("email",20,255).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("recover").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form>';
|
||||
$output .= '<div class="accountOptions"><ul><li><a href="'.$session{page}{url}.'?op=createAccount">Create a new account.</a><li><a href="'.$session{page}{url}.'?op=displayLogin">Login.</a></ul></div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_recoverPasswordFinish {
|
||||
my ($sth, $username, $encryptedPassword, $userId, $password, $flag, $message, $output);
|
||||
$sth = WebGUI::SQL->read("select username, userId from user where email=".quote($session{form}{email}),$session{dbh});
|
||||
while (($username,$userId) = $sth->array) {
|
||||
foreach (0,1,2,3,4,5) {
|
||||
$password .= chr(ord('A') + randint(32));
|
||||
}
|
||||
$encryptedPassword = Digest::MD5::md5_base64($password);
|
||||
WebGUI::SQL->write("update user set identifier='$encryptedPassword' where userId='$userId'",$session{dbh});
|
||||
$flag = 1;
|
||||
$message = 'Someone (probably you) requested your account information be sent. Your password has been reset. The following information represents your new account information:\nUser: '.$username.'\nPass: '.$password.'\n';
|
||||
WebGUI::Mail::send($session{form}{email},"Account Information",$message);
|
||||
}
|
||||
$sth->finish();
|
||||
if ($flag) {
|
||||
$output = '<ul><li>Your account information has been sent to your email address.</ul>';
|
||||
$output .= www_displayLogin();
|
||||
} else {
|
||||
$output = '<ul><li>That email address is not in our databases.</ul>';
|
||||
$output .= www_recoverPassword();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_saveAccount {
|
||||
my ($output, $error, $uid, $encryptedPassword);
|
||||
if (_hasBadUsername($session{form}{username})) {
|
||||
$error = '<b>Error:</b> The account name <b>'.$session{form}{username}.'</b> is in use by another member of this site. Please try a different username, perhaps "'.$session{form}{username}.'too" or "'.$session{form}{username}.'01"<p>';
|
||||
}
|
||||
if (_hasBadPassword($session{form}{identifier1},$session{form}{identifier2})) {
|
||||
$error .= '<b>Error:</b> Your passwords did not match. Please try again.<p>';
|
||||
}
|
||||
if ($error eq "") {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
|
||||
$uid = getNextId("userId");
|
||||
WebGUI::SQL->write("insert into user set userId=".getNextId("userId").", username=".quote($session{form}{username}).", identifier=".quote($encryptedPassword).", email=".quote($session{form}{email}).", icq=".quote($session{form}{icq}),$session{dbh});
|
||||
WebGUI::SQL->write("insert into groupings set groupId=2,userId=$uid",$session{dbh});
|
||||
_login($uid,$encryptedPassword);
|
||||
$output .= 'Account created successfully!<p>';
|
||||
$output .= www_displayAccount();
|
||||
} else {
|
||||
$output = $error;
|
||||
$output = www_createAccount();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_updateAccount {
|
||||
my ($output, $error, $encryptedPassword, $passwordStatement);
|
||||
if ($session{var}{sessionId}) {
|
||||
if (_hasBadUsername($session{form}{username})) {
|
||||
$error = '<b>Error:</b> The account name <b>'.$session{form}{username}.'</b> is in use by another member of this site. Please try a different username, perhaps "'.$session{form}{username}.'too" or "'.$session{form}{username}.'01"<p>';
|
||||
}
|
||||
if ($session{form}{identifier1} ne "password" && _hasBadPassword($session{form}{identifier1},$session{form}{identifier2})) {
|
||||
$error .= '<b>Error:</b> Your passwords did not match. Please try again.<p>';
|
||||
} else {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
|
||||
$passwordStatement = ', identifier='.quote($encryptedPassword);
|
||||
}
|
||||
if ($error eq "") {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
|
||||
WebGUI::SQL->write("update user set username=".quote($session{form}{username}).$passwordStatement.", email=".quote($session{form}{email}).", icq=".quote($session{form}{icq})." where userId=".$session{user}{userId},$session{dbh});
|
||||
if ($passwordStatement ne "") {
|
||||
_login($session{user}{userId},$encryptedPassword);
|
||||
}
|
||||
$output .= 'Account updated successfully!<p>';
|
||||
$output .= www_displayAccount();
|
||||
} else {
|
||||
$output = $error;
|
||||
$output = www_createAccount();
|
||||
}
|
||||
} else {
|
||||
$output .= www_displayLogin();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
45
lib/WebGUI/Operation/Admin.pm
Normal file
45
lib/WebGUI/Operation/Admin.pm
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package WebGUI::Operation::Admin;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Exporter;
|
||||
use strict;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_switchOffAdmin &www_switchOnAdmin);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_switchOffAdmin {
|
||||
if ($session{var}{sessionId}) {
|
||||
WebGUI::SQL->write("update session set adminOn=0 where sessionId='$session{var}{sessionId}'",$session{dbh});
|
||||
WebGUI::Session::refreshSessionVars($session{var}{sessionId});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_switchOnAdmin {
|
||||
if ($session{var}{sessionId}) {
|
||||
WebGUI::SQL->write("update session set adminOn=1 where sessionId='$session{var}{sessionId}'",$session{dbh});
|
||||
WebGUI::Session::refreshSessionVars($session{var}{sessionId});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
156
lib/WebGUI/Operation/Group.pm
Normal file
156
lib/WebGUI/Operation/Group.pm
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
package WebGUI::Operation::Group;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Exporter;
|
||||
use strict;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_addGroup &www_addGroupSave &www_deleteGroup &www_deleteGroupConfirm &www_editGroup &www_editGroupSave &www_listGroups);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addGroup {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=17"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Add Group</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","addGroupSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Group Name</td><td>'.WebGUI::Form::text("groupName",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Description</td><td>'.WebGUI::Form::textArea("description",'').'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addGroupSave {
|
||||
my ($output);
|
||||
if ($session{var}{sessionId}) {
|
||||
WebGUI::SQL->write("insert into groups set groupId=".getNextId("groupId").", groupName=".quote($session{form}{groupName}).", description=".quote($session{form}{description}),$session{dbh});
|
||||
$output = www_listGroups();
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteGroup {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup(3) && $session{form}{gid} > 25) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=15"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
|
||||
$output .= 'Are you certain you wish to delete this group? Beware that deleting a group is permanent and will remove all privileges associated with this group.<p>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deleteGroupConfirm&gid='.$session{form}{gid}.'">Yes, I\'m sure.</a>';
|
||||
$output .= ' <a href="'.$session{page}{url}.'?op=listGroups">No, I made a mistake. </a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteGroupConfirm {
|
||||
if (WebGUI::Privilege::isInGroup(3) && $session{form}{gid} > 25) {
|
||||
WebGUI::SQL->write("delete from groups where groupId=$session{form}{gid}",$session{dbh});
|
||||
WebGUI::SQL->write("delete from groupings where groupId=$session{form}{gid}",$session{dbh});
|
||||
return www_listGroups();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editGroup {
|
||||
my ($output, $sth, %group, $user);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
%group = WebGUI::SQL->quickHash("select * from groups where groupId=$session{form}{gid}",$session{dbh});
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=13"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit Group</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","editGroupSave");
|
||||
$output .= WebGUI::Form::hidden("gid",$session{form}{gid});
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Group Name</td><td>'.WebGUI::Form::text("groupName",20,30,$group{groupName}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Description</td><td>'.WebGUI::Form::textArea("description",$group{description}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Users In Group</td><td valign="top">';
|
||||
$sth = WebGUI::SQL->read("select user.username from user,groupings where groupings.groupId=$session{form}{gid} and groupings.userId=user.userId order by user.username",$session{dbh});
|
||||
while (($user) = $sth->array) {
|
||||
$output .= $user."<br>";
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '<br></td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editGroupSave {
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("update groups set groupName=".quote($session{form}{groupName}).", description=".quote($session{form}{description})." where groupId=".$session{form}{gid},$session{dbh});
|
||||
return www_listGroups();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listGroups {
|
||||
my ($output, $sth, @data, $totalItems, $currentPage, $itemsPerPage);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$itemsPerPage = 50;
|
||||
if ($session{form}{pageNumber} < 1) {
|
||||
$currentPage = 1;
|
||||
} else {
|
||||
$currentPage = $session{form}{pageNumber};
|
||||
}
|
||||
($totalItems) = WebGUI::SQL->quickArray("select count(*) from groups where groupName<>'Reserved'",$session{dbh});
|
||||
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=10"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Groups</h1>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=addGroup">Add a new group.</a></div>';
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$sth = WebGUI::SQL->read("select groupId,groupName,description from groups where groupName<>'Reserved' order by groupName limit ".(($currentPage*$itemsPerPage)-$itemsPerPage).",".$itemsPerPage,$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
$output .= '<tr><td valign="top"><a href="'.$session{page}{url}.'?op=deleteGroup&gid='.$data[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?op=editGroup&gid='.$data[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a></td>';
|
||||
$output .= '<td valign="top">'.$data[1].'</td>';
|
||||
$output .= '<td valign="top">'.$data[2].'</td></tr>';
|
||||
}
|
||||
$output .= '</table><div class="pagination">';
|
||||
if ($currentPage > 1) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=listGroups&pageNumber='.($currentPage-1).'">«Previous Page</a>';
|
||||
} else {
|
||||
$output .= '«Previous Page';
|
||||
}
|
||||
$output .= ' · ';
|
||||
if ($currentPage < round($totalItems/$itemsPerPage)) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=listGroups&pageNumber='.($currentPage+1).'">Next Page»</a>';
|
||||
} else {
|
||||
$output .= 'Next Page»';
|
||||
}
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
71
lib/WebGUI/Operation/Help.pm
Normal file
71
lib/WebGUI/Operation/Help.pm
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
package WebGUI::Operation::Help;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Exporter;
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_viewHelp &www_viewHelpIndex);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewHelp {
|
||||
my ($output, %help, @data, $sth);
|
||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid}",$session{dbh});
|
||||
$output = '<h1>Help: '.$help{action}.' '.$help{object}.'</h1>';
|
||||
$help{body} =~ s/\n/\<br\>/g;
|
||||
$output .= $help{body};
|
||||
$output .= '<p><b>See Also:';
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object from help where object='$help{object}' and action<>'$help{action}' order by action",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
$output .= ' <a href="'.$session{page}{url}.'?op=viewHelp&hid='.$data[0].'">'.$data[1].' '.$data[2].'</a>';
|
||||
}
|
||||
$sth->finish;
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object from help where helpId in ($help{seeAlso}) order by action",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
$output .= ' <a href="'.$session{page}{url}.'?op=viewHelp&hid='.$data[0].'">'.$data[1].' '.$data[2].'</a>';
|
||||
}
|
||||
$sth->finish;
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewHelpIndex {
|
||||
my ($sth, @data, $output, $previous);
|
||||
$output = '<h1>Help Index</h1>';
|
||||
$output .= '<table width="100%"><tr><td valign="top"><b>Sorted By Action</b><p>';
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object from help order by action,object",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
if ($data[1] ne $previous) {
|
||||
$output .= '<p><b>'.$data[1].'</b><br>';
|
||||
$previous = $data[1];
|
||||
}
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=viewHelp&hid='.$data[0].'">'.$data[2].'</a><br>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</td><td valign="top"><b>Sorted By Object</b><p>';
|
||||
$sth = WebGUI::SQL->read("select helpId, object, action from help order by object,action",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
if ($data[1] ne $previous) {
|
||||
$output .= '<p><b>'.$data[1].'</b><br>';
|
||||
$previous = $data[1];
|
||||
}
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=viewHelp&hid='.$data[0].'">'.$data[2].'</a><br>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</td></tr></table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
190
lib/WebGUI/Operation/Page.pm
Normal file
190
lib/WebGUI/Operation/Page.pm
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
package WebGUI::Operation::Page;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Exporter;
|
||||
use strict;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_addPage &www_addPageSave &www_cutPage &www_deletePage &www_deletePageConfirm &www_editPage &www_editPageSave &www_pastePage);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _recursivelyChangePrivileges {
|
||||
my ($sth, $pageId);
|
||||
$sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0]",$session{dbh});
|
||||
while (($pageId) = $sth->array) {
|
||||
WebGUI::SQL->write("update page set ownerId=$session{form}{ownerId}, ownerView=$session{form}{ownerView}, ownerEdit=$session{form}{ownerEdit}, groupId='$session{form}{groupId}', groupView=$session{form}{groupView}, groupEdit=$session{form}{groupEdit}, worldView=$session{form}{worldView}, worldEdit=$session{form}{worldEdit} where pageId=$pageId",$session{dbh});
|
||||
_recursivelyChangePrivileges($pageId);
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _recursivelyChangeStyle {
|
||||
my ($sth, $pageId);
|
||||
$sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0]",$session{dbh});
|
||||
while (($pageId) = $sth->array) {
|
||||
WebGUI::SQL->write("update page set styleId=$session{form}{styleId} where pageId=$pageId",$session{dbh});
|
||||
_recursivelyChangeStyle($pageId);
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addPage {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=1"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Add Page</h1><form method="post" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("op","addPageSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$session{form}{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Meta Tags</td><td>'.WebGUI::Form::textArea("metaTags",$session{form}{metaTags}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("create").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addPageSave {
|
||||
my (%parent, $urlizedTitle, $test);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%parent = WebGUI::SQL->quickHash("select * from page where pageId=$session{page}{pageId}",$session{dbh});
|
||||
$urlizedTitle = urlizeTitle($session{form}{title});
|
||||
while (($test) = WebGUI::SQL->quickArray("select urlizedTitle from page where urlizedTitle='$urlizedTitle'",$session{dbh})) {
|
||||
$urlizedTitle .= 2;
|
||||
}
|
||||
WebGUI::SQL->write("insert into page set pageId=".getNextId("pageId").", parentId=$session{page}{pageId}, title=".quote($session{form}{title}).", styleId=$parent{styleId}, ownerId=$session{user}{userId}, ownerView=$parent{ownerView}, ownerEdit=$parent{ownerEdit}, groupId='$parent{groupId}', groupView=$parent{groupView}, groupEdit=$parent{groupEdit}, worldView=$parent{worldView}, worldEdit=$parent{worldEdit}, metaTags=".quote($session{form}{metaTags}).", urlizedTitle='$urlizedTitle'",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_cutPage {
|
||||
if (WebGUI::Privilege::canEditPage() && $session{page}{pageId}!=1) {
|
||||
WebGUI::SQL->write("update page set parentId=2 where pageId=".$session{page}{pageId},$session{dbh});
|
||||
WebGUI::Session::refreshPageInfo($session{page}{parentId});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deletePage {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage() && $session{page}{pageId}!=1) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=3"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
|
||||
$output .= 'Are you certain that you wish to delete this page, its content, and all items under it?<p>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deletePageConfirm">Yes, I\'m sure.</a>';
|
||||
$output .= ' <a href="'.$session{page}{url}.'">No, I made a mistake.</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deletePageConfirm {
|
||||
if (WebGUI::Privilege::canEditPage() && $session{page}{pageId}!=1) {
|
||||
WebGUI::SQL->write("update page set parentId=3 where pageId=".$session{page}{pageId},$session{dbh});
|
||||
WebGUI::Session::refreshPageInfo($session{page}{parentId});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editPage {
|
||||
my ($output, %yesNo, %hash, @array);
|
||||
tie %hash, "Tie::IxHash";
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%yesNo = ("0"=>"No", "1"=>"Yes");
|
||||
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=2"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit Page</h1><form method="post" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("op","editPageSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$session{page}{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Meta Tags</td><td>'.WebGUI::Form::textArea("metaTags",$session{page}{metaTags}).'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select styleId,name from style where name<>'Reserved' order by name",$session{dbh});
|
||||
$array[0] = $session{page}{styleId};
|
||||
$output .= '<tr><td class="formDescription">Style</td><td>'.WebGUI::Form::selectList("styleId",\%hash,\@array).' '.WebGUI::Form::checkbox("recurseStyle","yes").' <span class="formSubtext">Check to give this style to all sub-pages.</span></td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Page URL</td><td>'.WebGUI::Form::text("urlizedTitle",20,30,$session{page}{urlizedTitle}).'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select user.userId,user.username from user,groupings where groupings.groupId=4 and groupings.userId=user.userId order by user.username",$session{dbh});
|
||||
$array[0] = $session{page}{ownerId};
|
||||
$output .= '<tr><td class="formDescription">Owner</td><td>'.WebGUI::Form::selectList("ownerId",\%hash,\@array).' '.WebGUI::Form::checkbox("recursePrivs","yes").' <span class="formSubtext">Check to give these privileges to all sub-pages.</span></td></tr>';
|
||||
$array[0] = $session{page}{ownerView};
|
||||
$output .= '<tr><td class="formDescription">Owner can view?</td><td>'.WebGUI::Form::selectList("ownerView",\%yesNo,\@array).'</td></tr>';
|
||||
$array[0] = $session{page}{ownerEdit};
|
||||
$output .= '<tr><td class="formDescription">Owner can edit?</td><td>'.WebGUI::Form::selectList("ownerEdit",\%yesNo,\@array).'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
|
||||
$array[0] = $session{page}{groupId};
|
||||
$output .= '<tr><td class="formDescription">Group</td><td>'.WebGUI::Form::selectList("groupId",\%hash,\@array).'</td></tr>';
|
||||
$array[0] = $session{page}{groupView};
|
||||
$output .= '<tr><td class="formDescription">Group can view?</td><td>'.WebGUI::Form::selectList("groupView",\%yesNo,\@array).'</td></tr>';
|
||||
$array[0] = $session{page}{groupEdit};
|
||||
$output .= '<tr><td class="formDescription">Group can edit?</td><td>'.WebGUI::Form::selectList("groupEdit",\%yesNo,\@array).'</td></tr>';
|
||||
$array[0] = $session{page}{worldView};
|
||||
$output .= '<tr><td class="formDescription">Anybody can view?</td><td>'.WebGUI::Form::selectList("worldView",\%yesNo,\@array).'</td></tr>';
|
||||
$array[0] = $session{page}{worldEdit};
|
||||
$output .= '<tr><td class="formDescription">Anybody can Edit?</td><td>'.WebGUI::Form::selectList("worldEdit",\%yesNo,\@array).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editPageSave {
|
||||
my (%parent, $urlizedTitle, $test);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$urlizedTitle = urlizeTitle($session{form}{urlizedTitle});
|
||||
while (($test) = WebGUI::SQL->quickArray("select urlizedTitle from page where urlizedTitle='$urlizedTitle' and pageId<>$session{page}{pageId}",$session{dbh})) {
|
||||
$urlizedTitle .= 2;
|
||||
}
|
||||
WebGUI::SQL->write("update page set title=".quote($session{form}{title}).", styleId=$session{form}{styleId}, ownerId=$session{form}{ownerId}, ownerView=$session{form}{ownerView}, ownerEdit=$session{form}{ownerEdit}, groupId='$session{form}{groupId}', groupView=$session{form}{groupView}, groupEdit=$session{form}{groupEdit}, worldView=$session{form}{worldView}, worldEdit=$session{form}{worldEdit}, metaTags=".quote($session{form}{metaTags}).", urlizedTitle='$urlizedTitle' where pageId=$session{page}{pageId}",$session{dbh});
|
||||
if ($session{form}{recurseStyle} eq "yes") {
|
||||
_recursivelyChangeStyle($session{page}{pageId});
|
||||
}
|
||||
if ($session{form}{recursePrivs} eq "yes") {
|
||||
_recursivelyChangePrivileges($session{page}{pageId});
|
||||
}
|
||||
WebGUI::Session::refreshPageInfo($session{page}{pageId});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_pastePage {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update page set parentId=$session{page}{pageId} where pageId=$session{form}{pageId}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
68
lib/WebGUI/Operation/Settings.pm
Normal file
68
lib/WebGUI/Operation/Settings.pm
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package WebGUI::Operation::Settings;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Exporter;
|
||||
use strict;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_editSettings &www_editSettingsSave);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSettings {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=12"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit Settings</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","editSettingsSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Path to WebGUI Extras</td><td>'.WebGUI::Form::text("lib",20,255,$session{setting}{lib}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Session Timeout</td><td>'.WebGUI::Form::text("sessionTimeout",20,11,$session{setting}{sessionTimeout}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Maximum Attachment Size</td><td>'.WebGUI::Form::text("maxAttachmentSize",20,11,$session{setting}{maxAttachmentSize}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Web Attachment Path</td><td>'.WebGUI::Form::text("attachmentDirectoryWeb",20,255,$session{setting}{attachmentDirectoryWeb}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Server Attachment Path</td><td>'.WebGUI::Form::text("attachmentDirectoryLocal",20,255,$session{setting}{attachmentDirectoryLocal}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">SMTP Server</td><td>'.WebGUI::Form::text("smtpServer",20,255,$session{setting}{smtpServer}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Company Name</td><td>'.WebGUI::Form::text("companyName",20,255,$session{setting}{companyName}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Company Email Address</td><td>'.WebGUI::Form::text("companyEmail",20,255,$session{setting}{companyEmail}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Company URL</td><td>'.WebGUI::Form::text("companyURL",20,255,$session{setting}{companyURL}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
$output .= '<hr size=1>Build Version: '.$session{wg}{version}.'<br>Release Date: '.$session{wg}{date};
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSettingsSave {
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{lib})." where name='lib'",$session{dbh});
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{sessionTimeout})." where name='sessionTimeout'",$session{dbh});
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{maxAttachmentSize})." where name='maxAttachmentSize'",$session{dbh});
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{attachmentDirectoryWeb})." where name='attachmentDirectoryWeb'",$session{dbh});
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{attachmentDirectoryLocal})." where name='attachmentDirectoryLocal'",$session{dbh});
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{smtpServer})." where name='smtpServer'",$session{dbh});
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{companyName})." where name='companyName'",$session{dbh});
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{companyEmail})." where name='companyEmail'",$session{dbh});
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{companyURL})." where name='companyURL'",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
153
lib/WebGUI/Operation/Style.pm
Normal file
153
lib/WebGUI/Operation/Style.pm
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
package WebGUI::Operation::Style;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Exporter;
|
||||
use strict;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_addStyle &www_addStyleSave &www_deleteStyle &www_deleteStyleConfirm &www_editStyle &www_editStyleSave &www_listStyles);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addStyle {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=16"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Add Style</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","addStyleSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Style Name</td><td>'.WebGUI::Form::text("name",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Header</td><td>'.WebGUI::Form::textArea("header",'',50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Footer</td><td>'.WebGUI::Form::textArea("footer",'',50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Style Sheet</td><td>'.WebGUI::Form::textArea("styleSheet",'<style> </style>',50,10).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addStyleSave {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("insert into style set styleId=".getNextId("styleId")." name=".quote($session{form}{name}).", header=".quote($session{form}{header}).", footer=".quote($session{form}{footer}).", styleSheet=".quote($session{form}{styleSheet}),$session{dbh});
|
||||
$output = www_listStyles();
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteStyle {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup(3) && $session{form}{sid} > 25) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=4"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
|
||||
$output .= 'Are you certain you wish to delete this style and migrate all pages using this style to the "Fail Safe" style?<p>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deleteStyleConfirm&sid='.$session{form}{sid}.'">Yes, I\'m sure.</a>';
|
||||
$output .= ' <a href="'.$session{page}{url}.'?op=listStyles">No, I made a mistake.</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteStyleConfirm {
|
||||
if (WebGUI::Privilege::isInGroup(3) && $session{form}{sid} > 25) {
|
||||
WebGUI::SQL->write("delete from style where styleId=".$session{form}{sid},$session{dbh});
|
||||
WebGUI::SQL->write("update page set styleId=2 where styleId=".$session{form}{sid},$session{dbh});
|
||||
return www_listStyles();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editStyle {
|
||||
my ($output, %style);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
%style = WebGUI::SQL->quickHash("select * from style where styleId=$session{form}{sid}",$session{dbh});
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=11"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit Style</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","editStyleSave");
|
||||
$output .= WebGUI::Form::hidden("sid",$session{form}{sid});
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Style Name</td><td>'.WebGUI::Form::text("name",20,30,$style{name}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Header</td><td>'.WebGUI::Form::textArea("header",$style{header},50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Footer</td><td>'.WebGUI::Form::textArea("footer",$style{footer},50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Style Sheet</td><td>'.WebGUI::Form::textArea("styleSheet",$style{styleSheet},50,10).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editStyleSave {
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("update style set name=".quote($session{form}{name}).", header=".quote($session{form}{header}).", footer=".quote($session{form}{footer}).", styleSheet=".quote($session{form}{styleSheet})." where styleId=".$session{form}{sid},$session{dbh});
|
||||
return www_listStyles();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listStyles {
|
||||
my ($output, $sth, @data, $totalItems, $currentPage, $itemsPerPage);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$itemsPerPage = 50;
|
||||
if ($session{form}{pageNumber} < 1) {
|
||||
$currentPage = 1;
|
||||
} else {
|
||||
$currentPage = $session{form}{pageNumber};
|
||||
}
|
||||
($totalItems) = WebGUI::SQL->quickArray("select count(*) from style where name<>'Reserved'",$session{dbh});
|
||||
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=9"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Styles</h1>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=addStyle">Add a new style.</a></div>';
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$sth = WebGUI::SQL->read("select styleId,name from style where name<>'Reserved' order by name limit ".(($currentPage*$itemsPerPage)-$itemsPerPage).",".$itemsPerPage,$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
$output .= '<tr><td valign="top"><a href="'.$session{page}{url}.'?op=deleteStyle&sid='.$data[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?op=editStyle&sid='.$data[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a></td>';
|
||||
$output .= '<td valign="top">'.$data[1].'</td>';
|
||||
}
|
||||
$output .= '</table><div class="pagination">';
|
||||
if ($currentPage > 1) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=listGroups&pageNumber='.($currentPage-1).'">«Previous Page</a>';
|
||||
} else {
|
||||
$output .= '«Previous Page';
|
||||
}
|
||||
$output .= ' · ';
|
||||
if ($currentPage < round($totalItems/$itemsPerPage)) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=listGroups&pageNumber='.($currentPage+1).'">Next Page»</a>';
|
||||
} else {
|
||||
$output .= 'Next Page»';
|
||||
}
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
179
lib/WebGUI/Operation/User.pm
Normal file
179
lib/WebGUI/Operation/User.pm
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
package WebGUI::Operation::User;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Digest::MD5 qw(md5_base64);
|
||||
use Exporter;
|
||||
use strict;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Operation::Help;
|
||||
use WebGUI::Operation::Page;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_addUser &www_addUserSave &www_deleteUser &www_deleteUserConfirm &www_editUser &www_editUserSave &www_listUsers);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addUser {
|
||||
my ($output, %hash);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=5"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Add User</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","addUserSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Username</td><td>'.WebGUI::Form::text("username",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Password</td><td>'.WebGUI::Form::password("identifier",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">Email address</td><td>'.WebGUI::Form::text("email",20,255).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top"><a href="http://www.icq.com">ICQ</a> UIN</td><td>'.WebGUI::Form::text("icq",20,30).'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
|
||||
$output .= '<tr><td class="formDescription" valign="top">Groups</td><td>'.WebGUI::Form::selectList("groups",\%hash,'',5,1).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addUserSave {
|
||||
my ($output, @groups, $uid, $gid, $encryptedPassword, $passwordStatement);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
|
||||
$passwordStatement = ', identifier='.quote($encryptedPassword);
|
||||
$uid = getNextId("userId");
|
||||
WebGUI::SQL->write("insert into user set userId=$uid, username=".quote($session{form}{username}).$passwordStatement.", email=".quote($session{form}{email}).", icq=".quote($session{form}{icq}),$session{dbh});
|
||||
@groups = $session{cgi}->param('groups');
|
||||
foreach $gid (@groups) {
|
||||
WebGUI::SQL->write("insert into groupings set groupId=$gid, userId=$uid",$session{dbh});
|
||||
}
|
||||
$output = www_listUsers();
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteUser {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup(3) && $session{form}{uid} > 25) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=7"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
|
||||
$output .= 'Are you certain you want to delete this user? Be warned that all this user\'s information will be lost permanently if you choose to proceed.<p>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=deleteUserConfirm&uid='.$session{form}{uid}.'">Yes, I\'m sure.</a>';
|
||||
$output .= ' <a href="'.$session{page}{url}.'?op=listUsers">No, I made a mistake.</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteUserConfirm {
|
||||
if (WebGUI::Privilege::isInGroup(3) && $session{form}{uid} > 25) {
|
||||
WebGUI::SQL->write("delete from user where userId=$session{form}{uid}",$session{dbh});
|
||||
WebGUI::SQL->write("delete from groupings where userId=$session{form}{uid}",$session{dbh});
|
||||
return www_listUsers();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUser {
|
||||
my ($output, %user, %hash, @array);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
%user = WebGUI::SQL->quickHash("select * from user where userId=$session{form}{uid}",$session{dbh});
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=6"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Edit User</h1> <form method="post" action="'.$session{page}{url}.'"> ';
|
||||
$output .= WebGUI::Form::hidden("op","editUserSave");
|
||||
$output .= WebGUI::Form::hidden("uid",$session{form}{uid});
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">username</td><td>'.WebGUI::Form::text("username",20,30,$user{username}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">password</td><td>'.WebGUI::Form::password("identifier",20,30,"password").'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top">email address</td><td>'.WebGUI::Form::text("email",20,255,$user{email}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription" valign="top"><a href="http://www.icq.com">ICQ</a> UIN</td><td>'.WebGUI::Form::text("icq",20,30,$user{icq}).'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
|
||||
@array = WebGUI::SQL->buildArray("select groupId from groupings where userId=$session{form}{uid}",$session{dbh});
|
||||
$output .= '<tr><td class="formDescription" valign="top">Groups</td><td>'.WebGUI::Form::selectList("groups",\%hash,\@array,5,1).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editUserSave {
|
||||
my (@groups, $error, $gid, $encryptedPassword, $passwordStatement);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
if ($session{form}{identifier} ne "password") {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
$passwordStatement = ', identifier='.quote($encryptedPassword);
|
||||
}
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
|
||||
WebGUI::SQL->write("update user set username=".quote($session{form}{username}).$passwordStatement.", email=".quote($session{form}{email}).", icq=".quote($session{form}{icq})." where userId=".$session{form}{uid},$session{dbh});
|
||||
WebGUI::SQL->write("delete from groupings where userId=$session{form}{uid}",$session{dbh});
|
||||
@groups = $session{cgi}->param('groups');
|
||||
foreach $gid (@groups) {
|
||||
WebGUI::SQL->write("insert into groupings set groupId=$gid, userId=$session{form}{uid}",$session{dbh});
|
||||
}
|
||||
return www_listUsers();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listUsers {
|
||||
my ($output, $sth, @data, $totalItems, $currentPage, $itemsPerPage);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$itemsPerPage = 50;
|
||||
if ($session{form}{pageNumber} < 1) {
|
||||
$currentPage = 1;
|
||||
} else {
|
||||
$currentPage = $session{form}{pageNumber};
|
||||
}
|
||||
($totalItems) = WebGUI::SQL->quickArray("select count(*) from user where username<>'Reserved'",$session{dbh});
|
||||
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=8"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Users</h1>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?op=addUser">Add a new user.</a></div>';
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$sth = WebGUI::SQL->read("select userId,username,email from user where username<>'Reserved' order by username limit ".(($currentPage*$itemsPerPage)-$itemsPerPage).",".$itemsPerPage,$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
$output .= '<tr><td><a href="'.$session{page}{url}.'?op=deleteUser&uid='.$data[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?op=editUser&uid='.$data[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a></td>';
|
||||
$output .= '<td><a href="'.$session{page}{url}.'?op=viewUserProfile&uid='.$data[0].'">'.$data[1].'</a></td>';
|
||||
$output .= '<td><a href="mailto:'.$data[2].'">'.$data[2].'</a></td></tr>';
|
||||
}
|
||||
$output .= '</table><div class="pagination">';
|
||||
if ($currentPage > 1) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=listUsers&pageNumber='.($currentPage-1).'">«Previous Page</a>';
|
||||
} else {
|
||||
$output .= '«Previous Page';
|
||||
}
|
||||
$output .= ' · ';
|
||||
if ($currentPage < round($totalItems/$itemsPerPage)) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=listUsers&pageNumber='.($currentPage+1).'">Next Page»</a>';
|
||||
} else {
|
||||
$output .= 'Next Page»';
|
||||
}
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
75
lib/WebGUI/Privilege.pm
Normal file
75
lib/WebGUI/Privilege.pm
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
package WebGUI::Privilege;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub canEditPage {
|
||||
if ($session{page}{worldEdit}) {
|
||||
return 1;
|
||||
} elsif ($session{user}{userId} eq $session{page}{ownerId} && $session{page}{ownerEdit}) {
|
||||
return 1;
|
||||
} elsif (isInGroup(3)) {
|
||||
return 1;
|
||||
} elsif (isInGroup($session{page}{groupId}) && $session{page}{groupEdit}) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub canViewPage {
|
||||
my (%page);
|
||||
if ($_[0] eq "") {
|
||||
%page = %{$session{page}};
|
||||
} else {
|
||||
%page = WebGUI::SQL->quickHash("select * from page where pageId=$_[0]",$session{dbh});
|
||||
}
|
||||
if ($page{worldView}) {
|
||||
return 1;
|
||||
} elsif ($session{user}{userId} eq $page{ownerId} && $page{ownerView}) {
|
||||
return 1;
|
||||
} elsif (isInGroup(3)) {
|
||||
return 1;
|
||||
} elsif (isInGroup($page{groupId}) && $page{groupView}) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub insufficient {
|
||||
return '<h1>Permission Denied!</h1>You do not have sufficient privileges to perform this operation. Please log in with an account that has sufficient privileges before attempting this operation.<p>';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub isInGroup {
|
||||
my ($gid, $uid, $result);
|
||||
($gid, $uid) = @_;
|
||||
if ($uid eq "") {
|
||||
$uid = $session{user}{userId};
|
||||
}
|
||||
($result) = WebGUI::SQL->quickArray("select count(*) from groupings where groupId='$gid' && userId='$uid'",$session{dbh});
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
105
lib/WebGUI/SQL.pm
Normal file
105
lib/WebGUI/SQL.pm
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 CGI::Carp qw(fatalsToBrowser);
|
||||
use DBI;
|
||||
use strict;
|
||||
use Tie::IxHash;
|
||||
|
||||
# Note: This class is really not necessary, I just decided to wrapper DBI in case
|
||||
# I wanted to change to some other DB connector in the future. Also, it shorthands
|
||||
# a few tasks.
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub array {
|
||||
return $_[0]->{_sth}->fetchrow_array() or croak DBI->errstr;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub buildArray {
|
||||
my ($sth, $data, @array, $i);
|
||||
$sth = WebGUI::SQL->read($_[1],$_[2]);
|
||||
$i=0;
|
||||
while (($data) = $sth->array) {
|
||||
$array[$i] = $data;
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
return @array;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub buildHash {
|
||||
my ($sth, %hash, @data);
|
||||
tie %hash, "Tie::IxHash";
|
||||
$sth = WebGUI::SQL->read($_[1],$_[2]);
|
||||
while (@data = $sth->array) {
|
||||
$hash{$data[0]} = $data[1];
|
||||
}
|
||||
$sth->finish;
|
||||
return %hash;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub finish {
|
||||
return $_[0]->{_sth}->finish;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub hash {
|
||||
return $_[0]->{_sth}->fetchrow_hashref() or croak DBI->errstr;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub new {
|
||||
my ($class, $sql, $dbh, $sth);
|
||||
$class = shift;
|
||||
$sql = shift;
|
||||
$dbh = shift;
|
||||
$sth = $dbh->prepare($sql) or croak "Couldn't prepare statement: ".$sql." : ". DBI->errstr;
|
||||
$sth->execute or croak "Couldn't execute statement: ".$sql." : ". DBI->errstr;
|
||||
bless ({_sth => $sth}, $class);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub quickArray {
|
||||
my ($sth, @data);
|
||||
$sth = WebGUI::SQL->new($_[1],$_[2]);
|
||||
@data = $sth->array;
|
||||
$sth->finish;
|
||||
return @data;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub quickHash {
|
||||
my ($sth, $data);
|
||||
$sth = WebGUI::SQL->new($_[1],$_[2]);
|
||||
$data = $sth->hash;
|
||||
$sth->finish;
|
||||
if (defined $data) {
|
||||
return %{$data};
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub read {
|
||||
return WebGUI::SQL->new($_[1],$_[2]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub write {
|
||||
$_[2]->do($_[1]) or croak "Couldn't prepare statement: ".$_[1]." : ". DBI->errstr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
172
lib/WebGUI/Session.pm
Normal file
172
lib/WebGUI/Session.pm
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
package WebGUI::Session;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 CGI;
|
||||
use DBI;
|
||||
use Exporter;
|
||||
use strict;
|
||||
use WebGUI::Config;
|
||||
use WebGUI::SQL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(%session);
|
||||
our %session = ();
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _getPageInfo {
|
||||
my (%page, $pageId, $pageName);
|
||||
($pageId) = $_[0];
|
||||
if ($pageId eq "") {
|
||||
$pageName = lc($ENV{PATH_INFO});
|
||||
$pageName =~ s/\///;
|
||||
if ($pageName ne "") {
|
||||
($pageId) = WebGUI::SQL->quickArray("select pageId from page where urlizedTitle='".$pageName."'",$_[1]);
|
||||
if ($pageId eq "") {
|
||||
$pageId = 1;
|
||||
}
|
||||
} else {
|
||||
$pageId = 1;
|
||||
}
|
||||
}
|
||||
%page = WebGUI::SQL->quickHash("select * from page where pageId='".$pageId."'",$_[1]);
|
||||
$page{url} = $ENV{SCRIPT_NAME}."/".$page{urlizedTitle};
|
||||
return %page;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _getSessionVars {
|
||||
my (%vars, $uid, $encryptedPassword);
|
||||
if ($_[0] ne "") {
|
||||
%vars = WebGUI::SQL->quickHash("select * from session where sessionId='$_[0]'", $_[1]);
|
||||
if ($vars{sessionId} ne "") {
|
||||
WebGUI::SQL->write("update session set lastPageView=now(), expires=date_add(now(),interval $_[2] second) where sessionId='$_[0]'",$_[1]);
|
||||
}
|
||||
}
|
||||
return %vars;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _getUserInfo {
|
||||
my (%user, $uid, $encryptedPassword);
|
||||
if ($_[0] ne "") {
|
||||
($uid, $encryptedPassword) = split(/\|/,$_[0]);
|
||||
} else {
|
||||
$uid = 1;
|
||||
}
|
||||
%user = WebGUI::SQL->quickHash("select * from user where userId='$uid'", $_[1]);
|
||||
if ($user{userId} eq "") {
|
||||
%user = _getUserInfo(1,$_[1]);
|
||||
}
|
||||
return %user;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub close {
|
||||
$session{'dbh'}->disconnect();
|
||||
undef %session;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub end {
|
||||
WebGUI::SQL->write("delete from session where sessionId='$_[0]'",$session{dbh});
|
||||
refreshSessionVars();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub httpHeader {
|
||||
return $session{cgi}->header( -cookie => $session{header}{cookie});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub httpRedirect {
|
||||
return $session{cgi}->redirect($_[0]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub open {
|
||||
my ($key, %WebGUI, %CONFIG, %VARS, %PAGE, %FORM, $query, %COOKIES, $config, %USER, %SETTINGS, $dbh);
|
||||
%WebGUI = (version=>"0.9.0", date=>"2001-08-13");
|
||||
$config = new WebGUI::Config '../etc/WebGUI.conf';
|
||||
foreach ($config->param) {
|
||||
$CONFIG{$_} = $config->param($_);
|
||||
}
|
||||
$dbh = DBI->connect($CONFIG{dsn}, $CONFIG{dbuser}, $CONFIG{dbpass});
|
||||
$query = CGI->new();
|
||||
foreach ($query->param) {
|
||||
$FORM{$_} = $query->param($_);
|
||||
}
|
||||
foreach ($query->cookie) {
|
||||
$COOKIES{$_} = $query->cookie($_);
|
||||
}
|
||||
%SETTINGS = WebGUI::SQL->buildHash("select name,value from settings",$dbh);
|
||||
%VARS = _getSessionVars($COOKIES{wgSession},$dbh,$SETTINGS{sessionTimeout});
|
||||
%USER = _getUserInfo($VARS{sessionId},$dbh);
|
||||
$CGI::POST_MAX=1024 * $SETTINGS{maxAttachmentSize};
|
||||
%PAGE = _getPageInfo("",$dbh);
|
||||
%session = (
|
||||
env => \%ENV, # environment variables from the web server
|
||||
# config=> \%CONFIG, # variables loaded from the config file
|
||||
user => \%USER, # the user's account information
|
||||
var => \%VARS, # session specific variables
|
||||
form => \%FORM, # variables passed in from a form
|
||||
cookie => \%COOKIES, # variables passed in via cookie
|
||||
setting => \%SETTINGS, # variables set by the administrator
|
||||
cgi => $query, # interface to the CGI environment
|
||||
page => \%PAGE, # variables related to the current page
|
||||
header => {}, # settings to be passed back through the http header
|
||||
dbh => $dbh, # interface to the default WebGUI database
|
||||
wg => \%WebGUI # WebGUI internal settings
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub refreshPageInfo {
|
||||
my (%PAGE);
|
||||
%PAGE = _getPageInfo($_[0],$session{dbh});
|
||||
$session{page} = \%PAGE;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub refreshSessionVars {
|
||||
my (%VARS);
|
||||
%VARS = _getSessionVars($_[0],$session{dbh},$session{setting}{sessionTimeout});
|
||||
$session{var} = \%VARS;
|
||||
refreshUserInfo($session{var}{sessionId});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub refreshUserInfo {
|
||||
my (%USER);
|
||||
%USER = _getUserInfo($_[0],$session{dbh});
|
||||
$session{user} = \%USER;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub setCookie {
|
||||
$session{header}{cookie} = $session{cgi}->cookie(-name=>$_[0], -value=>$_[1], -expires=>'+10y', -path=>'/');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub start {
|
||||
my (%user, $uid, $encryptedPassword);
|
||||
($uid, $encryptedPassword) = split(/\|/,$_[0]);
|
||||
%user = WebGUI::SQL->quickHash("select * from user where userId='$uid'", $session{dbh});
|
||||
if (crypt($user{identifier},"yJ") eq $encryptedPassword) {
|
||||
WebGUI::SQL->write("insert into session set sessionId='$_[0]', expires=date_add(now(),interval $session{setting}{sessionTimeout} second)",$session{dbh});
|
||||
refreshSessionVars($_[0]);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
39
lib/WebGUI/Style.pm
Normal file
39
lib/WebGUI/Style.pm
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package WebGUI::Style;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Macro;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getStyle {
|
||||
my ($header, $footer, @style, %style);
|
||||
%style = WebGUI::SQL->quickHash("select header,footer,styleSheet from style where styleId=$session{page}{styleId}",$session{dbh});
|
||||
$header = '<html>
|
||||
<head>
|
||||
<title>'.$session{page}{title}.'</title>'.$style{styleSheet}.$session{page}{metaTags}.'
|
||||
<script language="JavaScript" src="'.$session{setting}{lib}.'/WebGUI.js"></script>
|
||||
</head>
|
||||
<!-- WebGUI '.$session{wg}{version}.' -->
|
||||
'.$style{header};
|
||||
$footer = $style{footer};
|
||||
$header = WebGUI::Macro::process($header);
|
||||
$footer = WebGUI::Macro::process($footer);
|
||||
return ($header, $footer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
83
lib/WebGUI/Utility.pm
Normal file
83
lib/WebGUI/Utility.pm
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
package WebGUI::Utility;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 CGI;
|
||||
use Exporter;
|
||||
use FileHandle;
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&getNextId &saveAttachment &humanToMysqlDate &round &urlizeTitle "e);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getNextId {
|
||||
my ($id);
|
||||
($id) = WebGUI::SQL->quickArray("select nextValue from incrementer where incrementerId='$_[0]'",$session{dbh});
|
||||
WebGUI::SQL->write("update incrementer set nextValue=nextValue+1 where incrementerId='$_[0]'",$session{dbh});
|
||||
return $id;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub humanToMysqlDate {
|
||||
my ($month, $day, $year) = split(/\//,$_[0]);
|
||||
return $year.'-'.$month.'-'.$day.' 00:00:00';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# This is here simply to make typing shorter, cuz I'm lazy.
|
||||
sub quote {
|
||||
return $session{dbh}->quote($_[0]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub round {
|
||||
return sprintf("%.0f", $_[0]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# eg: saveAttachment(formVarName,widgetId);
|
||||
sub saveAttachment {
|
||||
my ($file, $filename, $bytesread, $buffer, $urlizedFilename);
|
||||
$filename = $session{cgi}->upload($_[0]);
|
||||
#$filename = $session{form}{$_[0]};
|
||||
#$filename = $session{cgi}->param($_[0]);
|
||||
if (defined $filename) {
|
||||
$urlizedFilename = urlizeTitle($filename);
|
||||
mkdir ($session{setting}{attachmentDirectoryLocal}."/".$_[1],0755);
|
||||
$file = FileHandle->new(">".$session{setting}{attachmentDirectoryLocal}."/".$_[1]."/".$urlizedFilename);
|
||||
if (defined $file) {
|
||||
while ($bytesread=read($filename,$buffer,1024)) {
|
||||
print $file $buffer;
|
||||
}
|
||||
close($file);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return $urlizedFilename;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub urlizeTitle {
|
||||
my ($title);
|
||||
$title = lc($_[0]);
|
||||
$title =~ s/ /_/g;
|
||||
$title =~ s/[^a-z0-9\-\.\_]//g;
|
||||
return $title;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
129
lib/WebGUI/Widget.pm
Normal file
129
lib/WebGUI/Widget.pm
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
package WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 CGI::Carp qw(fatalsToBrowser);
|
||||
use DBI;
|
||||
use Exporter;
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&update &www_moveUp &www_moveDown &www_delete &www_deleteConfirm &www_cut &create &www_paste);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _reorderWidgets {
|
||||
my ($sth, $i, $wid);
|
||||
$sth = WebGUI::SQL->read("select widgetId from widget where pageId=$_[0] order by sequenceNumber",$session{dbh});
|
||||
while (($wid) = $sth->array) {
|
||||
WebGUI::SQL->write("update widget set sequenceNumber='$i' where widgetId=$wid",$session{dbh});
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub create {
|
||||
my ($widgetId, $nextSeq);
|
||||
$widgetId = getNextId("widgetId");
|
||||
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from widget where pageId=$session{page}{pageId}",$session{dbh});
|
||||
WebGUI::SQL->write("insert into widget set widgetId=$widgetId, pageId=$session{page}{pageId}, widgetType='$session{form}{widget}', title=".quote($session{form}{title}).", displayTitle='$session{form}{displayTitle}', description=".quote($session{form}{description}).", sequenceNumber='$nextSeq'",$session{dbh});
|
||||
return $widgetId;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub update {
|
||||
WebGUI::SQL->write("update widget set title=".quote($session{form}{title}).", displayTitle='$session{form}{displayTitle}', description=".quote($session{form}{description}).", processMacros='$session{form}{processMacros}' where widgetId=$session{form}{wid}",$session{dbh});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_cut {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update widget set pageId=2 where widgetId=".$session{form}{wid},$session{dbh});
|
||||
_reorderWidgets($session{page}{pageId});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_delete {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output .= '<a href="'.$session{page}{url}.'?op=viewHelp&hid=14"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a><h1>Please Confirm</h1>';
|
||||
$output .= 'Are you certain that you wish to delete this content?<p>';
|
||||
$output .= '<div align="center"><a href="'.$session{page}{url}.'?func=deleteConfirm&wid='.$session{form}{wid}.'">Yes, I\'m sure.</a>';
|
||||
$output .= ' <a href="'.$session{page}{url}.'">No, I made a mistake.</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteConfirm {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update widget set pageId=3 where widgetId=".$session{form}{wid},$session{dbh});
|
||||
_reorderWidgets($session{page}{pageId});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveDown {
|
||||
my (@data, $thisSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from widget where widgetId=$session{form}{wid}",$session{dbh});
|
||||
@data = WebGUI::SQL->quickArray("select widgetId, min(sequenceNumber) from widget where pageId=$session{page}{pageId} and sequenceNumber>$thisSeq group by pageId",$session{dbh});
|
||||
if ($data[0] ne "") {
|
||||
WebGUI::SQL->write("update widget set sequenceNumber=sequenceNumber+1 where widgetId=$session{form}{wid}",$session{dbh});
|
||||
WebGUI::SQL->write("update widget set sequenceNumber=sequenceNumber-1 where widgetId=$data[0]",$session{dbh});
|
||||
}
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveUp {
|
||||
my (@data, $thisSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from widget where widgetId=$session{form}{wid}",$session{dbh});
|
||||
@data = WebGUI::SQL->quickArray("select widgetId, max(sequenceNumber) from widget where pageId=$session{page}{pageId} and sequenceNumber<$thisSeq group by pageId",$session{dbh});
|
||||
if ($data[0] ne "") {
|
||||
WebGUI::SQL->write("update widget set sequenceNumber=sequenceNumber-1 where widgetId=$session{form}{wid}",$session{dbh});
|
||||
WebGUI::SQL->write("update widget set sequenceNumber=sequenceNumber+1 where widgetId=$data[0]",$session{dbh});
|
||||
}
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_paste {
|
||||
my ($output, $nextSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from widget where pageId=$session{page}{pageId}",$session{dbh});
|
||||
WebGUI::SQL->write("update widget set pageId=$session{page}{pageId}, sequenceNumber='$nextSeq' where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
174
lib/WebGUI/Widget/Article.pm
Normal file
174
lib/WebGUI/Widget/Article.pm
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
package WebGUI::Widget::Article;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Macro;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Article";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Article</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","Article");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros",1,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Start Date</td><td>'.WebGUI::Form::text("startDate",20,30,'01/01/2000',1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">End Date</td><td>'.WebGUI::Form::text("endDate",20,30,'01/01/2100',1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Body</td><td>'.WebGUI::Form::textArea("body",'',50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Image</td><td>'.WebGUI::Form::file("image").'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Link Title</td><td>'.WebGUI::Form::text("linkTitle",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Link URL</td><td>'.WebGUI::Form::text("linkURL",20,2048).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Attachment</td><td>'.WebGUI::Form::file("attachment").'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId, $displayTitle, $image, $attachment);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
$image = saveAttachment("image",$widgetId);
|
||||
$attachment = saveAttachment("attachment",$widgetId);
|
||||
WebGUI::SQL->write("insert into Article set widgetId=$widgetId, startDate='".humanToMysqlDate($session{form}{startDate})."', endDate='".humanToMysqlDate($session{form}{endDate})."', body=".quote($session{form}{body}).", image=".quote($image).", linkTitle=".quote($session{form}{linkTitle}).", linkURL=".quote($session{form}{linkURL}).", attachment=".quote($attachment),$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteAttachment {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update Article set attachment='' where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteImage {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update Article set image='' where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %article);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%article = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle, date_format(Article.startDate,'%m/%d/%Y') as start, date_format(Article.endDate,'%m/%d/%Y') as end, Article.body, Article.image, Article.linkTitle, Article.linkURL, Article.attachment, widget.processMacros from widget left join Article on (widget.widgetId=Article.widgetId) where widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Article</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$article{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$article{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros","1",$article{processMacros}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Start Date</td><td>'.WebGUI::Form::text("startDate",20,30,$article{start},1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">End Date</td><td>'.WebGUI::Form::text("endDate",20,30,$article{end},1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Body</td><td>'.WebGUI::Form::textArea("body",$article{body},50,10,1).'</td></tr>';
|
||||
if ($article{image} ne "") {
|
||||
$output .= '<tr><td class="formDescription">Image</td><td><a href="'.$session{page}{url}.'?func=deleteImage&wid='.$session{form}{wid}.'">Delete Image</a></td></tr>';
|
||||
} else {
|
||||
$output .= '<tr><td class="formDescription">Image</td><td>'.WebGUI::Form::file("image").'</td></tr>';
|
||||
}
|
||||
$output .= '<tr><td class="formDescription">Link Title</td><td>'.WebGUI::Form::text("linkTitle",20,30,$article{linkTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Link URL</td><td>'.WebGUI::Form::text("linkURL",20,2048,$article{linkURL}).'</td></tr>';
|
||||
if ($article{attachment} ne "") {
|
||||
$output .= '<tr><td class="formDescription">Attachment</td><td><a href="'.$session{page}{url}.'?func=deleteAttachment&wid='.$session{form}{wid}.'">Delete Attachment</a></td></tr>';
|
||||
} else {
|
||||
$output .= '<tr><td class="formDescription">Attachment</td><td>'.WebGUI::Form::file("attachment").'</td></tr>';
|
||||
}
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
my ($widgetId, $displayTitle, $image, $attachment);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
$image = saveAttachment("image",$session{form}{wid});
|
||||
if ($image ne "") {
|
||||
$image = ', image='.quote($image);
|
||||
}
|
||||
$attachment = saveAttachment("attachment",$session{form}{wid});
|
||||
if ($attachment ne "") {
|
||||
$attachment = ', attachment='.quote($attachment);
|
||||
}
|
||||
WebGUI::SQL->write("update Article set startDate='".humanToMysqlDate($session{form}{startDate})."', endDate='".humanToMysqlDate($session{form}{endDate})."', body=".quote($session{form}{body}).", linkTitle=".quote($session{form}{linkTitle}).", linkURL=".quote($session{form}{linkURL}).$attachment.$image." where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, @test, $output, $widgetId);
|
||||
$widgetId = shift;
|
||||
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle, widget.processMacros, Article.body, Article.image, Article.linkTitle, Article.linkURL, Article.attachment from widget,Article where widget.widgetId='$widgetId' and widget.WidgetId=Article.widgetId and Article.startDate<now() and Article.endDate>now()",$session{dbh});
|
||||
if (defined %data) {
|
||||
if ($data{displayTitle} == 1) {
|
||||
$output = "<h2>".$data{title}."</h2>";
|
||||
}
|
||||
if ($data{image} ne "") {
|
||||
$output .= '<img src="'.$session{setting}{attachmentDirectoryWeb}.'/'.$widgetId.'/'.$data{image}.'" border="0" align="right">';
|
||||
}
|
||||
$output .= $data{body};
|
||||
if ($data{linkURL} ne "" && $data{linkTitle} ne "") {
|
||||
$output .= '<p><a href="'.$data{linkURL}.'">'.$data{linkTitle}.'</a>';
|
||||
}
|
||||
if ($data{attachment} ne "") {
|
||||
$output .= '<p><a href="'.$session{setting}{attachmentDirectoryWeb}.'/'.$widgetId.'/'.$data{attachment}.'">[attachment: '.$data{attachment}.']</a>';
|
||||
}
|
||||
}
|
||||
if ($data{processMacros} == 1) {
|
||||
$output = WebGUI::Macro::process($output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
217
lib/WebGUI/Widget/EventsCalendar.pm
Normal file
217
lib/WebGUI/Widget/EventsCalendar.pm
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
package WebGUI::Widget::EventsCalendar;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Events Calendar";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Events Calendar</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","EventsCalendar");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1").'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addEvent {
|
||||
my ($output, $today);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($today) = WebGUI::SQL->quickArray("select date_format(date_add(now(), interval 1 day),'%m/%d/%Y')",$session{dbh});
|
||||
$output = '<h1>Add Event</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","addEventSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Name</td><td>'.WebGUI::Form::text("name",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'',50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Start Date</td><td>'.WebGUI::Form::text("startDate",20,30,$today,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">End Date</td><td>'.WebGUI::Form::text("endDate",20,30,$today,1).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addEventSave {
|
||||
my ($eventId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$eventId = getNextId("eventId");
|
||||
WebGUI::SQL->write("insert into event set widgetId=$session{form}{wid}, eventId=$eventId, name=".quote($session{form}{name}).", description=".quote($session{form}{description}).", startDate='".humanToMysqlDate($session{form}{startDate})."', endDate='".humanToMysqlDate($session{form}{endDate})."'",$session{dbh});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteEvent {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Please Confirm</h1>';
|
||||
$output = 'Are you certain that you want to delete this event?<p><div align="center"><a href="'.$session{page}{url}.'?func=deleteEventConfirm&wid='.$session{form}{wid}.'&eid='.$session{form}{eid}.'">Yes, I\'m sure.</a> <a href="'.$session{page}{url}.'?func=edit&wid='.$session{form}{wid}.'">No, I made a mistake.</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteEventConfirm {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("delete from event where eventId=$session{form}{eid}",$session{dbh});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data, @event, $sth);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle from widget where widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Events Calendar</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
$output .= '<p><a href="'.$session{page}{url}.'?func=addEvent&wid='.$session{form}{wid}.'">Add New Event</a><p>';
|
||||
$output .= '<table border=1 cellpadding=3 cellspacing=0>';
|
||||
$sth = WebGUI::SQL->read("select eventId, name from event where widgetId='$session{form}{wid}' order by startDate",$session{dbh});
|
||||
while (@event = $sth->array) {
|
||||
$output .= '<tr><td><a href="'.$session{page}{url}.'?func=editEvent&wid='.$session{form}{wid}.'&eid='.$event[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.$session{page}{url}.'?func=deleteEvent&wid='.$session{form}{wid}.'&eid='.$event[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a></td><td>'.$event[1].'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editEvent {
|
||||
my ($output, %event);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%event = WebGUI::SQL->quickHash("select name, description, date_format(startDate,'%m/%d/%Y') as start, date_format(endDate,'%m/%d/%Y') as end from event where eventId='$session{form}{eid}'",$session{dbh});
|
||||
$output = '<h1>Edit Event</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("eid",$session{form}{eid});
|
||||
$output .= WebGUI::Form::hidden("func","editEventSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Name</td><td>'.WebGUI::Form::text("name",20,30,$event{name}).'</td></tr>'
|
||||
;
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$event{description},50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Start Date</td><td>'.WebGUI::Form::text("startDate",20,30,$event{start},1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">End Date</td><td>'.WebGUI::Form::text("endDate",20,30,$event{end},1).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editEventSave {
|
||||
my ($eventId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update event set name=".quote($session{form}{name}).", description=".quote($session{form}{description}).", startDate='".humanToMysqlDate($session{form}{startDate})."', endDate='".humanToMysqlDate($session{form}{endDate})."' where eventId=$session{form}{eid}",$session{dbh});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, @event, $output, $widgetId, $sth);
|
||||
$widgetId = shift;
|
||||
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle from widget where widget.widgetId='$widgetId'",$session{dbh});
|
||||
if (defined %data) {
|
||||
if ($data{displayTitle} == 1) {
|
||||
$output = "<h2>".$data{title}."</h2>";
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select name, description, date_format(startDate,'%M'), date_format(startDate,'%e'), date_format(startDate,'%Y'), date_format(endDate,'%e') from event where widgetId='$widgetId' and startDate>now() order by startDate",$session{dbh});
|
||||
while (@event = $sth->array) {
|
||||
$output .= "<b>$event[2] $event[3]";
|
||||
if ($event[3] ne $event[5]) {
|
||||
$output .= "-$event[5]";
|
||||
}
|
||||
$output .= ", $event[4]</b>";
|
||||
$output .= "<hr size=1>";
|
||||
$output .= '<table cellpadding=3 cellspacing=0 border=0><tr>';
|
||||
$output .= '<td valign="top">'.$event[0].' - </td>';
|
||||
$output .= '<td valign="top">'.$event[1].'</td>';
|
||||
$output .= '</tr></table><p>';
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
107
lib/WebGUI/Widget/ExtraColumn.pm
Normal file
107
lib/WebGUI/Widget/ExtraColumn.pm
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
package WebGUI::Widget::ExtraColumn;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Extra Column";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Column</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","ExtraColumn");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= WebGUI::Form::hidden("title","column");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Spacer</td><td>'.WebGUI::Form::text("spacer",20,3).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Width</td><td>'.WebGUI::Form::text("width",20,3).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">StyleSheet Class</td><td>'.WebGUI::Form::text("class",20,50).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId, $displayTitle, $image, $attachment);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
WebGUI::SQL->write("insert into ExtraColumn set widgetId=$widgetId, spacer='$session{form}{spacer}', width='$session{form}{width}', class=".quote($session{form}{class}),$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select * from ExtraColumn where widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Column</h1><form method="post" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= WebGUI::Form::hidden("title","column");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Spacer</td><td>'.WebGUI::Form::text("spacer",20,3,$data{spacer}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Width</td><td>'.WebGUI::Form::text("width",20,3,$data{width}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">StyleSheet Class</td><td>'.WebGUI::Form::text("class",20,30,$data{class}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
my ($widgetId, $displayTitle);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update ExtraColumn set spacer='$session{form}{spacer}', width='$session{form}{width}', class=".quote($session{form}{class})." where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, @test, $output, $widgetId);
|
||||
$widgetId = shift;
|
||||
%data = WebGUI::SQL->quickHash("select * from ExtraColumn where widgetId='$widgetId'",$session{dbh});
|
||||
if (defined %data) {
|
||||
$output = '</td><td width="'.$data{spacer}.'"></td><td width="'.$data{width}.'" class="'.$data{class}.'" valign="top">';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
258
lib/WebGUI/Widget/FAQ.pm
Normal file
258
lib/WebGUI/Widget/FAQ.pm
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
package WebGUI::Widget::FAQ;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Macro;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _reorderQuestions {
|
||||
my ($sth, $i, $qid);
|
||||
$sth = WebGUI::SQL->read("select questionId from faqQuestion where widgetId=$_[0] order by sequenceNumber",$session{dbh});
|
||||
while (($qid) = $sth->array) {
|
||||
WebGUI::SQL->write("update faqQuestion set sequenceNumber='$i' where questionId=$qid",$session{dbh});
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "F.A.Q.";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add F.A.Q.</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","FAQ");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Process Macros?</td><td>'.WebGUI::Form::checkbox("processMacros",1,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description").'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addQuestion {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Question</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","addQuestionSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Question</td><td>'.WebGUI::Form::textArea("question",'',50,3).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Answer</td><td>'.WebGUI::Form::textArea("answer").'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addQuestionSave {
|
||||
my ($questionId, $nextSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from faqQuestion where widgetId=$session{form}{wid}",$session{dbh});
|
||||
$questionId = getNextId("questionId");
|
||||
WebGUI::SQL->write("insert into faqQuestion set widgetId=$session{form}{wid}, questionId=$questionId, sequenceNumber='$nextSeq', question=".quote($session{form}{question}).", answer=".quote($session{form}{answer}),$session{dbh});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteQuestion {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Please Confirm</h1>';
|
||||
$output = 'Are you certain that you want to delete this question?<p><div align="center"><a href="'.$session{page}{url}.'?func=deleteQuestionConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid}.'">Yes, I\'m sure.</a> <a href="'.$session{page}{url}.'?func=edit&wid='.$session{form}{wid}.'">No, I made a mistake.</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteQuestionConfirm {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("delete from faqQuestions where questionId=$session{form}{qid}",$session{dbh});
|
||||
_reorderQuestions($session{form}{wid});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data, @question, $sth);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select * from widget where widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Link List</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros","1",$data{processMacros}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
$output .= '<p><a href="'.$session{page}{url}.'?func=addQuestion&wid='.$session{form}{wid}.'">Add New Question</a><p>';
|
||||
$output .= '<table border=1 cellpadding=3 cellspacing=0>';
|
||||
$sth = WebGUI::SQL->read("select questionId,question from faqQuestion where widgetId='$session{form}{wid}' order by sequenceNumber",$session{dbh});
|
||||
while (@question = $sth->array) {
|
||||
$output .= '<tr><td><a href="'.$session{page}{url}.'?func=editQuestion&wid='.$session{form}{wid}.'&qid='.$question[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.$session{page}{url}.'?func=deleteQuestion&wid='.$session{form}{wid}.'&qid='.$question[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveQuestionUp&wid='.$session{form}{wid}.'&qid='.$question[0].'"><img src="'.$session{setting}{lib}.'/upArrow.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveQuestionDown&wid='.$session{form}{wid}.'&qid='.$question[0].'"><img src="'.$session{setting}{lib}.'/downArrow.gif" border=0></a></td><td>'.$question[1].'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editQuestion {
|
||||
my ($output, %question);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%question = WebGUI::SQL->quickHash("select * from faqQuestion where questionId='$session{form}{qid}'",$session{dbh});
|
||||
$output = '<h1>Edit Question</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("qid",$session{form}{qid});
|
||||
$output .= WebGUI::Form::hidden("func","editQuestionSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Question</td><td>'.WebGUI::Form::textArea("question",$question{question},50,3).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Answer</td><td>'.WebGUI::Form::textArea("answer",$question{answer}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editQuestionSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update faqQuestion set question=".quote($session{form}{question}).", answer=".quote($session{form}{answer})." where questionId=$session{form}{qid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveQuestionDown {
|
||||
my (@data, $thisSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from faqQuestion where questionId=$session{form}{qid}",$session{dbh});
|
||||
@data = WebGUI::SQL->quickArray("select questionId, min(sequenceNumber) from faqQuestion where widgetId=$session{form}{wid} and sequenceNumber>$thisSeq group by widgetId",$session{dbh});
|
||||
if ($data[0] ne "") {
|
||||
WebGUI::SQL->write("update faqQuestion set sequenceNumber=sequenceNumber+1 where questionId=$session{form}{qid}",$session{dbh});
|
||||
WebGUI::SQL->write("update faqQuestion set sequenceNumber=sequenceNumber-1 where questionId=$data[0]",$session{dbh});
|
||||
}
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveQuestionUp {
|
||||
my (@data, $thisSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from faqQuestion where questionId=$session{form}{qid}",$session{dbh});
|
||||
@data = WebGUI::SQL->quickArray("select questionId, max(sequenceNumber) from faqQuestion where widgetId=$session{form}{wid} and sequenceNumber<$thisSeq group by widgetId",$session{dbh});
|
||||
if ($data[0] ne "") {
|
||||
WebGUI::SQL->write("update faqQuestion set sequenceNumber=sequenceNumber-1 where questionId=$session{form}{qid}",$session{dbh});
|
||||
WebGUI::SQL->write("update faqQuestion set sequenceNumber=sequenceNumber+1 where questionId=$data[0]",$session{dbh});
|
||||
}
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, @question, $output, $widgetId, $sth, $qNa);
|
||||
$widgetId = shift;
|
||||
%data = WebGUI::SQL->quickHash("select * from widget where widget.widgetId='$widgetId'",$session{dbh});
|
||||
if (defined %data) {
|
||||
if ($data{displayTitle} == 1) {
|
||||
$output = "<h2>".$data{title}."</h2>";
|
||||
}
|
||||
if ($data{description} ne "") {
|
||||
$output .= $data{description};
|
||||
}
|
||||
$output .= '<ul>';
|
||||
$sth = WebGUI::SQL->read("select questionId,question,answer from faqQuestion where widgetId='$widgetId' order by sequenceNumber",$session{dbh});
|
||||
while (@question = $sth->array) {
|
||||
$output .= '<li><a href="#'.$question[0].'">'.$question[1].'</a>';
|
||||
$qNa .= '<span class="faqQuestion"><a name="'.$question[0].'">'.$question[1].'</a></span><br>'.$question[2].'<p>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</ul>'.$qNa;
|
||||
}
|
||||
if ($data{processMacros} == 1) {
|
||||
$output = WebGUI::Macro::process($output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
253
lib/WebGUI/Widget/LinkList.pm
Normal file
253
lib/WebGUI/Widget/LinkList.pm
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
package WebGUI::Widget::LinkList;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _reorderLinks {
|
||||
my ($sth, $i, $lid);
|
||||
$sth = WebGUI::SQL->read("select linkId from link where widgetId=$_[0] order by sequenceNumber",$session{dbh});
|
||||
while (($lid) = $sth->array) {
|
||||
WebGUI::SQL->write("update link set sequenceNumber='$i' where linkId=$lid",$session{dbh});
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Link List";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Link List</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","LinkList");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1").'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addLink {
|
||||
my ($output, $today);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($today) = WebGUI::SQL->quickArray("select date_format(date_add(now(), interval 1 day),'%m/%d/%Y')",$session{dbh});
|
||||
$output = '<h1>Add Link</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","addLinkSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Name</td><td>'.WebGUI::Form::text("name",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">URL</td><td>'.WebGUI::Form::text("url",20,1024).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'',50,10).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addLinkSave {
|
||||
my ($linkId, $nextSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($nextSeq) = WebGUI::SQL->quickArray("select max(sequenceNumber)+1 from link where widgetId=$session{form}{wid}",$session{dbh});
|
||||
$linkId = getNextId("linkId");
|
||||
WebGUI::SQL->write("insert into link set widgetId=$session{form}{wid}, linkId=$linkId, name=".quote($session{form}{name}).", sequenceNumber='$nextSeq', url=".quote($session{form}{url}).", description=".quote($session{form}{description}),$session{dbh});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteLink {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Please Confirm</h1>';
|
||||
$output = 'Are you certain that you want to delete this link?<p><div align="center"><a href="'.$session{page}{url}.'?func=deleteLinkConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid}.'">Yes, I\'m sure.</a> <a href="'.$session{page}{url}.'?func=edit&wid='.$session{form}{wid}.'">No, I made a mistake.</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteLinkConfirm {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("delete from link where linkId=$session{form}{lid}",$session{dbh});
|
||||
_reorderLinks($session{form}{wid});
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data, @link, $sth);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle from widget where widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Link List</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
$output .= '<p><a href="'.$session{page}{url}.'?func=addLink&wid='.$session{form}{wid}.'">Add New Link</a><p>';
|
||||
$output .= '<table border=1 cellpadding=3 cellspacing=0>';
|
||||
$sth = WebGUI::SQL->read("select linkId, name from link where widgetId='$session{form}{wid}' order by sequenceNumber",$session{dbh});
|
||||
while (@link = $sth->array) {
|
||||
$output .= '<tr><td><a href="'.$session{page}{url}.'?func=editLink&wid='.$session{form}{wid}.'&lid='.$link[0].'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.$session{page}{url}.'?func=deleteLink&wid='.$session{form}{wid}.'&lid='.$link[0].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveLinkUp&wid='.$session{form}{wid}.'&lid='.$link[0].'"><img src="'.$session{setting}{lib}.'/upArrow.gif" border=0></a><a href="'.$session{page}{url}.'?func=moveLinkDown&wid='.$session{form}{wid}.'&lid='.$link[0].'"><img src="'.$session{setting}{lib}.'/downArrow.gif" border=0></a></td><td>'.$link[1].'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editLink {
|
||||
my ($output, %link);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%link = WebGUI::SQL->quickHash("select name, url, description from link where linkId='$session{form}{lid}'",$session{dbh});
|
||||
$output = '<h1>Edit Link</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("lid",$session{form}{lid});
|
||||
$output .= WebGUI::Form::hidden("func","editEventSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Name</td><td>'.WebGUI::Form::text("name",20,30,$link{name}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">URL</td><td>'.WebGUI::Form::text("url",20,2048,$link{url}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$link{description},50,10).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editLinkSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("update link set name=".quote($session{form}{name}).", url=".quote($session{form}{url}).", description=".quote($session{form}{description})." where linkId=$session{form}{lid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveLinkDown {
|
||||
my (@data, $thisSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from link where linkId=$session{form}{lid}",$session{dbh});
|
||||
@data = WebGUI::SQL->quickArray("select linkId, min(sequenceNumber) from link where widgetId=$session{form}{wid} and sequenceNumber>$thisSeq group by widgetId",$session{dbh});
|
||||
if ($data[0] ne "") {
|
||||
WebGUI::SQL->write("update link set sequenceNumber=sequenceNumber+1 where linkId=$session{form}{lid}",$session{dbh});
|
||||
WebGUI::SQL->write("update link set sequenceNumber=sequenceNumber-1 where linkId=$data[0]",$session{dbh});
|
||||
}
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveLinkUp {
|
||||
my (@data, $thisSeq);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($thisSeq) = WebGUI::SQL->quickArray("select sequenceNumber from link where linkId=$session{form}{lid}",$session{dbh});
|
||||
@data = WebGUI::SQL->quickArray("select linkId, max(sequenceNumber) from link where widgetId=$session{form}{wid} and sequenceNumber<$thisSeq group by widgetId",$session{dbh});
|
||||
if ($data[0] ne "") {
|
||||
WebGUI::SQL->write("update link set sequenceNumber=sequenceNumber-1 where linkId=$session{form}{lid}",$session{dbh});
|
||||
WebGUI::SQL->write("update link set sequenceNumber=sequenceNumber+1 where linkId=$data[0]",$session{dbh});
|
||||
}
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, @link, $output, $widgetId, $sth);
|
||||
$widgetId = shift;
|
||||
%data = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle from widget where widget.widgetId='$widgetId'",$session{dbh});
|
||||
if (defined %data) {
|
||||
if ($data{displayTitle} == 1) {
|
||||
$output = "<h2>".$data{title}."</h2>";
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select name, url, description from link where widgetId='$widgetId' order by sequenceNumber",$session{dbh});
|
||||
while (@link = $sth->array) {
|
||||
$output .= '<li><b><a href="'.$link[1].'">'.$link[0].'</a></b>';
|
||||
if ($link[2] ne "") {
|
||||
$output .= ' - '.$link[2];
|
||||
}
|
||||
$output .= '<br>';
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
359
lib/WebGUI/Widget/MessageBoard.pm
Normal file
359
lib/WebGUI/Widget/MessageBoard.pm
Normal file
|
|
@ -0,0 +1,359 @@
|
|||
package WebGUI::Widget::MessageBoard;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _getBoardProperties {
|
||||
my (%board);
|
||||
%board = WebGUI::SQL->quickHash("select widget.title, widget.displayTitle, widget.description, MessageBoard.groupToPost, MessageBoard.messagesPerPage, MessageBoard.editTimeout from widget left join MessageBoard on (widget.widgetId=MessageBoard.widgetId) where widget.widgetId=$_[0]",$session{dbh});
|
||||
return %board;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _traverseReplyTree {
|
||||
my ($sth, @data, $html, $depth, $i);
|
||||
for ($i=0;$i<=$_[1];$i++) {
|
||||
$depth .= " ";
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select messageId,substring(subject,1,30),username,date_format(dateOfPost,'%c/%e %l:%i%p') from message where pid=$_[0] order by messageId", $session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
$html .= '<tr';
|
||||
if ($session{form}{mid} eq $data[0]) {
|
||||
$html .= ' class="highlight"';
|
||||
}
|
||||
$html .= '><td class="boardData">'.$depth.'<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">'.$data[1].'</a></td><td class="boardData">'.$data[2].'</td><td class="boardData">'.$data[3].'</td></tr>';
|
||||
$html .= _traverseReplyTree($data[0],$_[1]+1);
|
||||
}
|
||||
$sth->finish;
|
||||
return $html;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Message Board";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output, %hash);
|
||||
tie %hash, "Tie::IxHash";
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Message Board</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","MessageBoard");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'').'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
|
||||
$output .= '<tr><td class="formDescription" valign="top">Who can post?</td><td>'.WebGUI::Form::selectList("groupToPost",\%hash,'',1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Messages Per Page</td><td>'.WebGUI::Form::text("messagesPerPage",20,2,50).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Edit Timeout</td><td>'.WebGUI::Form::text("editTimeout",20,3,1).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
WebGUI::SQL->write("insert into MessageBoard set widgetId=$widgetId, groupToPost=$session{form}{groupToPost}, messagesPerPage=$session{form}{messagesPerPage}, editTimeout=$session{form}{editTimeout}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %board, %hash, @array);
|
||||
tie %hash, "Tie::IxHash";
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%board = _getBoardProperties($session{form}{wid});
|
||||
$output = '<h1>Edit Message Board</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$board{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$board{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$board{description}).'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
|
||||
$array[0] = $board{groupToPost};
|
||||
$output .= '<tr><td class="formDescription" valign="top">Who can post?</td><td>'.WebGUI::Form::selectList("groupToPost",\%hash,\@array,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Messages Per Page</td><td>'.WebGUI::Form::text("messagesPerPage",20,2,$board{messagesPerPage}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Edit Timeout</td><td>'.WebGUI::Form::text("editTimeout",20,2,$board{editTimeout}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
WebGUI::SQL->write("update MessageBoard set groupToPost=$session{form}{groupToPost}, messagesPerPage=$session{form}{messagesPerPage}, editTimeout=$session{form}{editTimeout} where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editMessage {
|
||||
my ($html, %board, %message);
|
||||
%board = _getBoardProperties($session{form}{wid});
|
||||
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
|
||||
%message = WebGUI::SQL->quickHash("select * from message where messageId=$session{form}{mid}",$session{dbh});
|
||||
$html .= '<table width="100%"><tr><td class="boardTitle">';
|
||||
if ($board{displayTitle}) {
|
||||
$html .= $board{title};
|
||||
}
|
||||
$html .= '<td align="right" valign="bottom" class="boardMenu">Editing Message...</td></tr></table>';
|
||||
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
|
||||
$html .= WebGUI::Form::hidden("func","editMessageSave");
|
||||
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$html .= WebGUI::Form::hidden("mid",$session{form}{mid});
|
||||
$html .= '<tr><td class="formDescription">Subject</td><td>'.WebGUI::Form::text("subject",30,255,$message{subject}).'</td></tr>';
|
||||
$html .= '<tr><td class="formDescription" valign="top">Message</td><td>'.WebGUI::Form::textArea("message",$message{message},50,6,1).'</td></tr>';
|
||||
$html .= '<tr><td></td><td>'.WebGUI::Form::submit("Save This Edit").'</td></tr>';
|
||||
$html .= '</table></form>';
|
||||
$html .= www_showMessage();
|
||||
} else {
|
||||
$html = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editMessageSave {
|
||||
my (%board);
|
||||
%board = _getBoardProperties($session{form}{wid});
|
||||
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
|
||||
if ($session{form}{subject} eq "") {
|
||||
$session{form}{subject} = 'no subject';
|
||||
}
|
||||
if ($session{form}{message} eq "") {
|
||||
$session{form}{subject} .= ' (eom)';
|
||||
}
|
||||
WebGUI::SQL->write("update message set subject=".quote($session{form}{subject}).", message=".quote("\n --- (Edited at ".localtime(time).") --- \n\n".$session{form}{message})." where messageId=$session{form}{mid}",$session{dbh});
|
||||
return www_showMessage();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_postNewMessage {
|
||||
my ($html, %board);
|
||||
%board = _getBoardProperties($session{form}{wid});
|
||||
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
|
||||
$html .= '<table width="100%"><tr><td class="boardTitle">';
|
||||
if ($board{displayTitle}) {
|
||||
$html .= $board{title};
|
||||
}
|
||||
$html .= '<td align="right" valign="bottom" class="boardMenu">Posting New Message...</td></tr></table>';
|
||||
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
|
||||
$html .= WebGUI::Form::hidden("func","postNewMessageSave");
|
||||
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$html .= '<tr><td class="formDescription">Subject</td><td>'.WebGUI::Form::text("subject",30,255).'</td></tr>';
|
||||
$html .= '<tr><td class="formDescription" valign="top">Message</td><td>'.WebGUI::Form::textArea("message",'',50,6,1).'</td></tr>';
|
||||
$html .= '<tr><td></td><td>'.WebGUI::Form::submit("Post This Message").'</td></tr>';
|
||||
$html .= '</table></form>';
|
||||
} else {
|
||||
$html = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_postNewMessageSave {
|
||||
my ($mid, %board);
|
||||
%board = _getBoardProperties($session{form}{wid});
|
||||
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
|
||||
if ($session{form}{subject} eq "") {
|
||||
$session{form}{subject} = 'no subject';
|
||||
}
|
||||
if ($session{form}{message} eq "") {
|
||||
$session{form}{subject} .= ' (eom)';
|
||||
}
|
||||
$mid = getNextId("messageId");
|
||||
WebGUI::SQL->write("insert into message set messageId=$mid, userId=$session{user}{userId}, username=".quote($session{user}{username}).", subject=".quote($session{form}{subject}).", message=".quote($session{form}{message}).", widgetId=$session{form}{wid}, pid=0, dateOfPost=now()",$session{dbh});
|
||||
WebGUI::SQL->write("update message set rid=$mid where messageId=$mid",$session{dbh});
|
||||
return www_view($session{form}{wid});
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_postReply {
|
||||
my ($html, %board, $subject);
|
||||
%board = _getBoardProperties($session{form}{wid});
|
||||
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
|
||||
($subject) = WebGUI::SQL->quickArray("select subject from message where messageId=$session{form}{mid}", $session{dbh});
|
||||
$subject = "Re: ".$subject;
|
||||
$html .= '<table width="100%"><tr><td class="boardTitle">';
|
||||
if ($board{displayTitle}) {
|
||||
$html .= $board{title};
|
||||
}
|
||||
$html .= '<td align="right" valign="bottom" class="boardMenu">Posting Reply...</td></tr></table>';
|
||||
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
|
||||
$html .= WebGUI::Form::hidden("func","postReplySave");
|
||||
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$html .= WebGUI::Form::hidden("mid",$session{form}{mid});
|
||||
$html .= '<tr><td class="formDescription">Subject</td><td>'.WebGUI::Form::text("subject",30,255,$subject).'</td></tr>';
|
||||
$html .= '<tr><td class="formDescription" valign="top">Message</td><td>'.WebGUI::Form::textArea("message",'',50,6,1).'</td></tr>';
|
||||
$html .= '<tr><td></td><td>'.WebGUI::Form::submit("Post This Reply").'</td></tr>';
|
||||
$html .= '</table></form>';
|
||||
$html .= www_showMessage();
|
||||
} else {
|
||||
$html = WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_postReplySave {
|
||||
my ($rid, %board);
|
||||
%board = _getBoardProperties($session{form}{wid});
|
||||
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
|
||||
if ($session{form}{subject} eq "") {
|
||||
$session{form}{subject} = 'no subject';
|
||||
}
|
||||
if ($session{form}{message} eq "") {
|
||||
$session{form}{subject} .= ' (eom)';
|
||||
}
|
||||
($rid) = WebGUI::SQL->quickArray("select rid from message where messageId=$session{form}{mid}",$session{dbh});
|
||||
WebGUI::SQL->write("insert into message set userId=$session{user}{userId}, username=".quote($session{user}{username}).", subject=".quote($session{form}{subject}).", message=".quote($session{form}{message}).", rid=$rid, widgetId=$session{form}{wid}, pid=$session{form}{mid}, dateOfPost=now()", $session{dbh});
|
||||
return www_showMessage();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_showMessage {
|
||||
my (@data, $html, %board, %message);
|
||||
%message = WebGUI::SQL->quickHash("select * from message where messageId=$session{form}{mid}",$session{dbh});
|
||||
%board = _getBoardProperties($session{form}{wid});
|
||||
$html .= '<table width="100%"><tr><td class="boardTitle">';
|
||||
if ($board{displayTitle}) {
|
||||
$html .= $board{title};
|
||||
}
|
||||
$html .= '</td><td align="right" valign="bottom" class="boardMenu">';
|
||||
@data = WebGUI::SQL->quickArray("select unix_timestamp()-unix_timestamp(dateOfPost) from message where messageId=$session{form}{mid}",$session{dbh});
|
||||
if ($data[0] < 3600*$board{editTimeout} && $message{'userId'} eq $session{user}{userId}) {
|
||||
$html .= '<a href="'.$session{page}{url}.'?func=editMessage&mid='.$session{form}{mid}.'&wid='.$session{form}{wid}.'">Edit Message</a> · ';
|
||||
}
|
||||
$html .= '<a href="'.$session{page}{url}.'?func=postReply&mid='.$session{form}{mid}.'&wid='.$session{form}{wid}.'">Post Reply</a></td></tr></table>';
|
||||
$html .= '<table width="100%"><tr><td class="boardHeader">';
|
||||
$html .= "<b>Subject:</b> ".$message{subject}."<br>";
|
||||
$html .= "<b>Author:</b> ".$message{username}."<br>";
|
||||
$html .= "<b>Date:</b> ".$message{dateOfPost}."<br>";
|
||||
$html .= "<b>Message ID:</b> ".$message{widgetId}."-".$message{rid}."-".$message{pid}."-".$message{mid}."<br>";
|
||||
$html .= '</td>';
|
||||
$html .= '</tr><tr><td colspan=2 class="boardMessage">';
|
||||
$message{message} =~ s/\n/\<br\>/g;
|
||||
$html .= $message{message};
|
||||
$html .= '</td></tr></table><p><div align="center" class="boardMenu">';
|
||||
@data = WebGUI::SQL->quickArray("select max(messageId) from message where widgetId=$message{widgetId} and pid=0 and messageId<$message{rid}",$session{dbh});
|
||||
if ($data[0] ne "") {
|
||||
$html .= '<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">« Previous Thread</a>';
|
||||
} else {
|
||||
$html .= '« Previous Thread</a>';
|
||||
}
|
||||
$html .= ' · <a href="'.$session{page}{url}.'">Back To Message List</a> · ';
|
||||
@data = WebGUI::SQL->quickArray("select min(messageId) from message where widgetId=$message{widgetId} and pid=0 and messageId>$message{rid}",$session{dbh});
|
||||
if ($data[0] ne "") {
|
||||
$html .= '<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">Next Thread »</a>';
|
||||
} else {
|
||||
$html .= 'Next Thread »';
|
||||
}
|
||||
$html .= '</div><table border=0 cellpadding=2 cellspacing=1 width="100%">';
|
||||
$html .= '<tr><td class="boardHeader">Subject</td><td class="boardHeader">Author</td><td class="boardHeader">Date</td></tr>';
|
||||
@data = WebGUI::SQL->quickArray("select messageId,substring(subject,1,30),username,date_format(dateOfPost,'%c/%e %l:%i%p') from message where messageId=$message{rid}",$session{dbh});
|
||||
$html .= '<tr';
|
||||
if ($session{form}{mid} eq $message{rid}) {
|
||||
$html .= ' class="highlight"';
|
||||
}
|
||||
$html .= '><td class="boardData"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$message{widgetId}.'">'.$data[1].'</a></td><td class="boardData">'.$data[2].'</td><td class="boardData">'.$data[3].'</td></tr>';
|
||||
$html .= _traverseReplyTree($message{rid},1);
|
||||
$html .= "</table>";
|
||||
return $html;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my ($sth, @data, $html, %board, $itemsPerPage, $currentPage, $totalItems);
|
||||
%board = _getBoardProperties($_[0]);
|
||||
$itemsPerPage = $board{messagesPerPage};
|
||||
if ($session{form}{pageNumber} < 1) {
|
||||
$currentPage = 1;
|
||||
} else {
|
||||
$currentPage = $session{form}{pageNumber};
|
||||
}
|
||||
if ($board{description} ne "") {
|
||||
$html .= $board{description}.'<p>';
|
||||
}
|
||||
($totalItems) = WebGUI::SQL->quickArray("select count(*) from message where widgetId=$_[0]",$session{dbh});
|
||||
$html .= '<table width="100%"><tr><td class="boardTitle">';
|
||||
if ($board{displayTitle}) {
|
||||
$html .= $board{title};
|
||||
}
|
||||
$html .= '</td><td align="right" valign="bottom" class="boardMenu"><a href="'.$session{page}{url}.'?func=postNewMessage&wid='.$_[0].'">Post New Message</a></td></tr></table>';
|
||||
$html .= '<table border=0 cellpadding=2 cellspacing=1 width="100%">';
|
||||
$html .= '<tr><td class="boardHeader">Subject</td><td class="boardHeader">Author</td><td class="boardHeader">Thread Started</td><td class="boardHeader">Replies</td><td class="boardHeader">Last Reply</td></tr>';
|
||||
$sth = WebGUI::SQL->read("select messageId,substring(subject,1,30),count(messageId)-1,username,date_format(dateOfPost,'%c/%e %l:%i%p'),date_format(max(dateOfPost),'%c/%e %l:%i%p'),max(messageId) from message where widgetId=$_[0] group by rid order by messageId desc limit ".(($currentPage*$itemsPerPage)-$itemsPerPage).",".$itemsPerPage, $session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
$html .= '<tr><td class="boardData"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$_[0].'">'.$data[1].'</a></td><td class="boardData">'.$data[3].'</td><td class="boardData">'.$data[4].'</td><td class="boardData">'.$data[2].'</td><td class="boardData"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[6].'&wid='.$_[0].'">'.$data[5].'</a></td></tr>';
|
||||
}
|
||||
$html .= "</table>";
|
||||
$sth->finish;
|
||||
$html .= '<div class="pagination">';
|
||||
if ($currentPage > 1) {
|
||||
$html .= '<a href="'.$session{page}{url}.'?pageNumber='.($currentPage-1).'">«Previous Page</a>';
|
||||
} else {
|
||||
$html .= '«Previous Page';
|
||||
}
|
||||
$html .= ' · ';
|
||||
if ($currentPage < round($totalItems/$itemsPerPage)) {
|
||||
$html .= '<a href="'.$session{page}{url}.'?pageNumber='.($currentPage+1).'">Next Page»</a>';
|
||||
} else {
|
||||
$html .= 'Next Page»';
|
||||
}
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
182
lib/WebGUI/Widget/Poll.pm
Normal file
182
lib/WebGUI/Widget/Poll.pm
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
package WebGUI::Widget::Poll;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _viewPoll {
|
||||
my (%poll, $i, $output, $widgetId);
|
||||
$widgetId = shift;
|
||||
%poll = WebGUI::SQL->quickHash("select * from widget,Poll where widget.widgetId=Poll.widgetId and widget.widgetId='$widgetId'",$session{dbh});
|
||||
if (defined %poll) {
|
||||
if ($poll{displayTitle} == 1) {
|
||||
$output = "<h2>".$poll{title}."</h2>";
|
||||
}
|
||||
$output .= '<form method="post" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden('wid',$widgetId);
|
||||
$output .= WebGUI::Form::hidden('func','vote');
|
||||
$output .= '<span class="pollQuestion">'.$poll{question}.'</span><br>';
|
||||
for ($i=1; $i<=20; $i++) {
|
||||
if ($poll{'a'.$i} ne "") {
|
||||
$output .= WebGUI::Form::radio("answer",'a'.$i).' <span class="pollAnswer">'.$poll{'a'.$i}.'</span><br>';
|
||||
}
|
||||
}
|
||||
$output .= '<br>'.WebGUI::Form::submit('Vote!');
|
||||
|
||||
$output .= '</form>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _viewResults {
|
||||
my (%poll, @data, $i, $output, $widgetId, $totalResponses);
|
||||
$widgetId = shift;
|
||||
%poll = WebGUI::SQL->quickHash("select * from widget,Poll where widget.widgetId=Poll.widgetId and widget.widgetId='$widgetId'",$session{dbh});
|
||||
if (defined %poll) {
|
||||
if ($poll{displayTitle} == 1) {
|
||||
$output = "<h2>".$poll{title}."</h2>";
|
||||
}
|
||||
$output .= '<span class="pollQuestion">'.$poll{question}.'</span>';
|
||||
($totalResponses) = WebGUI::SQL->quickArray("select count(*) from pollAnswer where widgetId=$widgetId",$session{dbh});
|
||||
if ($totalResponses < 1) {
|
||||
$totalResponses = 1;
|
||||
}
|
||||
for ($i=1; $i<=20; $i++) {
|
||||
if ($poll{'a'.$i} ne "") {
|
||||
$output .= '<span class="pollAnswer"><hr size=1>'.$poll{'a'.$i}.'<br></span>';
|
||||
@data = WebGUI::SQL->quickArray("select count(*), answer from pollAnswer where answer='a$i' group by answer",$session{dbh});
|
||||
$output .= '<table cellpadding=0 cellspacing=0 border=0><tr><td width="'.round(150*$data[0]/$totalResponses).'" class="pollColor"></td><td class="pollAnswer"> '.round(100*$data[0]/$totalResponses).'%</td></tr></table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Poll";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output, %hash);
|
||||
tie %hash, "Tie::IxHash";
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Poll</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","Poll");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Active</td><td>'.WebGUI::Form::checkbox("active",1,1).'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
|
||||
$output .= '<tr><td class="formDescription" valign="top">Who can vote?</td><td>'.WebGUI::Form::selectList("voteGroup",\%hash,).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Question</td><td>'.WebGUI::Form::text("question",50,255).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Answers<span><br>(Enter one answer per line. No more than 20.)</span></td><td>'.WebGUI::Form::textArea("answers",'',50,8,0,'on').'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId, @answer);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
@answer = split("\n",$session{form}{answers});
|
||||
WebGUI::SQL->write("insert into Poll set widgetId=$widgetId, active='$session{form}{active}', voteGroup='$session{form}{voteGroup}', question=".quote($session{form}{question}).", a1=".quote($answer[0]).", a2=".quote($answer[1]).", a3=".quote($answer[2]).", a4=".quote($answer[3]).", a5=".quote($answer[4]).", a6=".quote($answer[5]).", a7=".quote($answer[6]).", a8=".quote($answer[7]).", a9=".quote($answer[8]).", a10=".quote($answer[9]).", a11=".quote($answer[10]).", a12=".quote($answer[11]).", a13=".quote($answer[12]).", a14=".quote($answer[13]).", a15=".quote($answer[14]).", a16=".quote($answer[15]).", a17=".quote($answer[16]).", a18=".quote($answer[17]).", a19=".quote($answer[18]).", a20=".quote($answer[19])."",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data, %hash, @array);
|
||||
tie %hash, "Tie::IxHash";
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,Poll where widget.widgetId=Poll.widgetId and widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Poll</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,$data{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Active</td><td>'.WebGUI::Form::checkbox("active",1,$data{active}).'</td></tr>';
|
||||
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where groupName<>'Reserved' order by groupName",$session{dbh});
|
||||
$array[0] = $data{voteGroup};
|
||||
$output .= '<tr><td class="formDescription" valign="top">Who can vote?</td><td>'.WebGUI::Form::selectList("voteGroup",\%hash,\@array).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Question</td><td>'.WebGUI::Form::text("question",50,255,$data{question}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Answers<span><br>(Enter one answer per line. No more than 20.)</span></td><td>'.WebGUI::Form::textArea("answers",$data{a1}."\n".$data{a2}."\n".$data{a3}."\n".$data{a4}."\n".$data{a5}."\n".$data{a6}."\n".$data{a7}."\n".$data{a8}."\n".$data{a9}."\n".$data{a10}."\n".$data{a11}."\n".$data{a12}."\n".$data{a13}."\n".$data{a14}."\n".$data{a15}."\n".$data{a16}."\n".$data{a17}."\n".$data{a18}."\n".$data{a19}."\n".$data{a20}."\n",50,8,0,'on').'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
my (@answer);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
@answer = split("\n",$session{form}{answers});
|
||||
WebGUI::SQL->write("update Poll set active='$session{form}{active}', voteGroup='$session{form}{voteGroup}', question=".quote($session{form}{question}).", a1=".quote($answer[0]).", a2=".quote($answer[1]).", a3=".quote($answer[2]).", a4=".quote($answer[3]).", a5=".quote($answer[4]).", a6=".quote($answer[5]).", a7=".quote($answer[6]).", a8=".quote($answer[7]).", a9=".quote($answer[8]).", a10=".quote($answer[9]).", a11=".quote($answer[10]).", a12=".quote($answer[11]).", a13=".quote($answer[12]).", a14=".quote($answer[13]).", a15=".quote($answer[14]).", a16=".quote($answer[15]).", a17=".quote($answer[16]).", a18=".quote($answer[17]).", a19=".quote($answer[18]).", a20=".quote($answer[19])." where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my ($hasVoted, %data, $output);
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,Poll where widget.widgetId=Poll.widgetId and widget.widgetId='$_[0]'",$session{dbh});
|
||||
if ($data{active} eq "0") {
|
||||
$output = _viewResults($_[0]);
|
||||
} elsif (WebGUI::Privilege::isInGroup($data{voteGroup},$session{user}{userId})) {
|
||||
($hasVoted) = WebGUI::SQL->quickArray("select count(*) from pollAnswer where userId=$session{user}{userId} and widgetId=$_[0]",$session{dbh});
|
||||
if ($hasVoted) {
|
||||
$output = _viewResults($_[0]);
|
||||
} else {
|
||||
$output = _viewPoll($_[0]);
|
||||
}
|
||||
} else {
|
||||
$output = _viewResults($_[0]);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_vote {
|
||||
WebGUI::SQL->write("insert into pollAnswer set widgetId=$session{form}{wid}, userId=$session{user}{userId}, answer='$session{form}{answer}'",$session{dbh});
|
||||
return _viewResults($session{form}{wid});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
146
lib/WebGUI/Widget/SQLReport.pm
Normal file
146
lib/WebGUI/Widget/SQLReport.pm
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
package WebGUI::Widget::SQLReport;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Macro;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "SQL Report";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add SQL Report</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","SQLReport");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros",1,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'','','',1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Template</td><td>'.WebGUI::Form::textArea("template",'','','',1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Query</td><td>'.WebGUI::Form::textArea("dbQuery",'').'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">DSN</td><td>'.WebGUI::Form::text("DSN",20,255,"DBI:mysql:").'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Database User</td><td>'.WebGUI::Form::text("username",20,255).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Database Password</td><td>'.WebGUI::Form::password("identifier",20,255).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
WebGUI::SQL->write("insert into SQLReport set widgetId=$widgetId, template=".quote($session{form}{template}).", dBquery=".quote($session{form}{dbQuery}).", DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier}),$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,SQLReport where widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit SQL Report</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Process macros?</td><td>'.WebGUI::Form::checkbox("processMacros","1",$data{processMacros}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description},50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Template</td><td>'.WebGUI::Form::textArea("template",$data{template},50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Query</td><td>'.WebGUI::Form::textArea("dbQuery",$data{dbQuery},50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">DSN</td><td>'.WebGUI::Form::text("DSN",20,255,$data{DSN}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Database User</td><td>'.WebGUI::Form::text("username",20,255,$data{username}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Database Password</td><td>'.WebGUI::Form::password("identifier",20,255,$data{identifier}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
my ($widgetId, $displayTitle, $image, $attachment);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
WebGUI::SQL->write("update SQLReport set template=".quote($session{form}{template}).", dbQuery=".quote($session{form}{dbQuery}).", DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier})." where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, $output, $widgetId, $sth, $dbh, @result, @template, $temp);
|
||||
$widgetId = shift;
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,SQLReport where widget.widgetId=$widgetId",$session{dbh});
|
||||
if (defined %data) {
|
||||
if ($data{displayTitle} == 1) {
|
||||
$output = "<h2>".$data{title}."</h2>";
|
||||
}
|
||||
if ($data{description} ne "") {
|
||||
$output .= $data{description}.'<p>';
|
||||
}
|
||||
@template = split(/\^\-/,$data{template});
|
||||
$output .= $template[0];
|
||||
$dbh = DBI->connect($data{DSN}, $data{username}, $data{identifier});
|
||||
if (defined $dbh) {
|
||||
$sth = WebGUI::SQL->read($data{dbQuery},$dbh);
|
||||
if (defined $sth) {
|
||||
while (@result = $sth->array) {
|
||||
$temp = $template[1];
|
||||
$temp =~ s/\^(\d)/$result[$1]/g;
|
||||
$output .= $temp;
|
||||
}
|
||||
$sth->finish;
|
||||
} else {
|
||||
$output .= '<b>Error</b>: There was a problem with the query.';
|
||||
}
|
||||
} else {
|
||||
$output .= '<b>Error</b>: Could not connect to remote database.';
|
||||
}
|
||||
$output .= $template[2];
|
||||
}
|
||||
if ($data{processMacros} == 1) {
|
||||
$output = WebGUI::Macro::process($output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
143
lib/WebGUI/Widget/SearchMnoGo.pm
Normal file
143
lib/WebGUI/Widget/SearchMnoGo.pm
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
package WebGUI::Widget::SearchMnoGo;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 DBI;
|
||||
use strict;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _mnogoSearch {
|
||||
my ($i, %match, $key, $sth, $dbh, $urlId, %data, $output, @keyword, $word, %result);
|
||||
%data = @_;
|
||||
@keyword = split(/ /,$session{form}{query});
|
||||
$dbh = DBI->connect($data{DSN},$data{username},$data{identifier});
|
||||
foreach $word (@keyword) {
|
||||
$sth = WebGUI::SQL->read("select url_id from dict where soundex(word)=soundex(lcase('$word'))",$dbh);
|
||||
while (($urlId) = $sth->array) {
|
||||
$result{$urlId}++;
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
foreach $key (sort {$result{$b} <=> $result{$a}} keys %result) {
|
||||
if ($i < 50) {
|
||||
%match = WebGUI::SQL->quickHash("select url,title,txt from url where rec_id=$key",$dbh);
|
||||
$output .= '<a href="'.$match{url}.'">'.$match{title}.'</a> ('.$result{$key}.')<br>'.$match{txt}.'<br><a href="'.$match{url}.'">'.$match{url}.'</a><p>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$dbh->disconnect();
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Search (MnoGo)";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Search (MnoGo)</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","SearchMnoGo");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'',50,5,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">DSN</td><td>'.WebGUI::Form::text("DSN",20,255).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Database User</td><td>'.WebGUI::Form::text("username",20,255).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Database Password</td><td>'.WebGUI::Form::password("identifier",20,255).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
WebGUI::SQL->write("insert into SearchMnoGo set widgetId=$widgetId, DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier}),$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,SearchMnoGo where widget.widgetId=SearchMnoGo.widgetId and widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Search (MnoGo)</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description},50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">DSN</td><td>'.WebGUI::Form::text("DSN",20,255,$data{DSN}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Database Username</td><td>'.WebGUI::Form::text("username",20,255,$data{username}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Database Password</td><td>'.WebGUI::Form::password("identifier",20,255,$data{identifier}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
WebGUI::SQL->write("update SearchMnoGo set DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier})." where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, @test, $output, $widgetId);
|
||||
$widgetId = shift;
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,SearchMnoGo where widget.widgetId='$widgetId' and widget.WidgetId=SearchMnoGo.widgetId",$session{dbh});
|
||||
if (%data) {
|
||||
if ($data{displayTitle} == 1) {
|
||||
$output = "<h2>".$data{title}."</h2>";
|
||||
}
|
||||
if ($data{description} ne "") {
|
||||
$output .= $data{description}.'<p>';
|
||||
}
|
||||
$output .= '<form method="post" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::text("query",20,255,$session{form}{query});
|
||||
$output .= WebGUI::Form::submit("search");
|
||||
$output .= '</form>';
|
||||
$output .= _mnogoSearch(%data);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
142
lib/WebGUI/Widget/SiteMap.pm
Normal file
142
lib/WebGUI/Widget/SiteMap.pm
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
package WebGUI::Widget::SiteMap;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _traversePageTree {
|
||||
my ($sth, @data, $output, $depth, $i);
|
||||
for ($i=0;$i<=$_[1];$i++) {
|
||||
$depth .= " ";
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select urlizedTitle, title, pageId from page where parentId='$_[0]'",$session{dbh});
|
||||
while (@data = $sth->array) {
|
||||
if (WebGUI::Privilege::canViewPage($data[2])) {
|
||||
$output .= $depth.'· <a href="'.$session{env}{SCRIPT_NAME}.'/'.$data[0].'">'.$data[1].'</a><br>';
|
||||
$output .= _traversePageTree($data[2],$_[1]+1);
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Site Map";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Site Map</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","SiteMap");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Disply title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'').'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Starting from this level?</td><td>'.WebGUI::Form::checkbox("startAtThisLevel",1,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Show only this level?</td><td>'.WebGUI::Form::checkbox("showOnlyThisLevel",1,1).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId, $displayTitle, $image, $attachment);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
WebGUI::SQL->write("insert into SiteMap set widgetId=$widgetId, startAtThisLevel='$session{form}{startAtThisLevel}', showOnlyThisLevel='$session{form}{showOnlyThisLevel}'",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,SiteMap where widget.widgetId=SiteMap.widgetId and widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Site Map</h1><form method="post" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Disply title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,$data{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Starting from this level?</td><td>'.WebGUI::Form::checkbox("startAtThisLevel",1,$data{startAtThisLevel}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Show only this level?uuuu</td><td>'.WebGUI::Form::checkbox("showOnlyThisLevel",1,$data{showOnlyThisLevel}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
WebGUI::SQL->write("update SiteMap set startAtThisLevel='$session{form}{startAtThisLevel}', showOnlyThisLevel='$session{form}{showOnlyThisLevel}' where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, $output, $sth, @root, $parent);
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,SiteMap where widget.widgetId=SiteMap.widgetId and widget.widgetId='$_[0]'",$session{dbh});
|
||||
if (defined %data) {
|
||||
if ($data{displayTitle} eq 1) {
|
||||
$output = '<h1>'.$data{title}.'</h1>';
|
||||
}
|
||||
$output .= $data{description}.'<p>';
|
||||
if ($data{startAtThisLevel} eq 1) {
|
||||
$parent = $session{page}{pageId};
|
||||
} else {
|
||||
$parent = 1;
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select urlizedTitle, title, pageId from page where parentId='$parent'",$session{dbh});
|
||||
while (@root = $sth->array) {
|
||||
if (WebGUI::Privilege::canViewPage($root[2])) {
|
||||
$output .= '· <a href="'.$session{env}{SCRIPT_NAME}.'/'.$root[0].'">'.$root[1].'</a><br>';
|
||||
unless ($data{showOnlyThisLevel} eq 1) {
|
||||
$output .= _traversePageTree($root[2],1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
112
lib/WebGUI/Widget/SyndicatedContent.pm
Normal file
112
lib/WebGUI/Widget/SyndicatedContent.pm
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
package WebGUI::Widget::SyndicatedContent;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Macro;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Widget;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub widgetName {
|
||||
return "Syndicated Content";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_add {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$output = '<h1>Add Syndicated Content</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("widget","SyndicatedContent");
|
||||
$output .= WebGUI::Form::hidden("func","addSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",'','','',1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">URL to RSS File</td><td>'.WebGUI::Form::text("rssUrl",20,2048).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addSave {
|
||||
my ($widgetId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create();
|
||||
WebGUI::SQL->write("insert into SyndicatedContent set widgetId=$widgetId, rssUrl=".quote($session{form}{rssUrl}).", content='Not yet fetched.'",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my ($output, %data);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,SyndicatedContent where widget.widgetId=$session{form}{wid}",$session{dbh});
|
||||
$output = '<h1>Edit Syndicated Content</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="formDescription">Title</td><td>'.WebGUI::Form::text("title",20,30,$data{title}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Display the title?</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Description</td><td>'.WebGUI::Form::textArea("description",$data{description},50,10,1).'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">URL to RSS File</td><td>'.WebGUI::Form::text("rssUrl",20,2048,$data{rssUrl}).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '<tr><td><br></td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Last Fetched</td><td>'.$data{lastFetched}.'</td></tr>';
|
||||
$output .= '<tr><td class="formDescription">Current Content</td><td>'.$data{content}.'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
WebGUI::SQL->write("update SyndicatedContent set rssUrl=".quote($session{form}{rssUrl})." where widgetId=$session{form}{wid}",$session{dbh});
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, $output, $widgetId);
|
||||
$widgetId = shift;
|
||||
%data = WebGUI::SQL->quickHash("select * from widget,SyndicatedContent where widget.widgetId=$widgetId",$session{dbh});
|
||||
if (defined %data) {
|
||||
if ($data{displayTitle} == 1) {
|
||||
$output = "<h2>".$data{title}."</h2>";
|
||||
}
|
||||
if ($data{description} ne "") {
|
||||
$output .= $data{description}.'<p>';
|
||||
}
|
||||
$output .= $data{content};
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue