fixed a bug in the new oo page tree stuff

removed a bunch of crap that somehow got readded
added new stuff for autogroups
got rid of magic groups
This commit is contained in:
JT Smith 2004-02-04 02:36:12 +00:00
parent bd4bf924f2
commit 0cb06e0e17
18 changed files with 102 additions and 1548 deletions

View file

@ -47,6 +47,15 @@ webgui.
- Added a limit option to the page list in the paginator.
- Fixed a bug in AdminBar's clipboard code where a standard hash was
used instead of a CPHash for database access. (Thanks to Steve Simms.)
- Added caching of complex data structures to WebGUI::Cache (Martin Kamerbeek / Procolix)
- Added caching of complex data structures to WebGUI::Cache (Martin Kamerbeek
/ Procolix). Note that this now requires Data::Serialzier to be installed.
- Implemented an object oriented interface to the page tree and converted
WebGUI::Operation::Page to use it. (Martin Kamerbeek / Procolix)
- Added two new methods (isEditable and showInForms) to the groups API to
make it easier to automagically create and use groups programatically without
disrupting the user experience.
- The everyone and registered users group are no longer magic in that there
are physical linkages between them and users. The magic was getting too
hard to maintain and users were confused by it.

View file

@ -20,6 +20,11 @@ save you many hours of grief.
* The Authentication Module API has been completely rewritten.
Please see docs/migration.txt for details.
* The Paginator API has been significantly changed.
Please see docs/migration.txt for details.
* WebGUI now requires Data::Serializer to be installed.
5.5.0
--------------------------------------------------------------------

View file

@ -345,7 +345,11 @@ INSERT INTO international VALUES (101,'DataForm',1,'Label',NULL,NULL);
INSERT INTO international VALUES (100,'DataForm',1,'Are you certain that you want to delete this tab ?',NULL,NULL);
INSERT INTO template VALUES (1,'Mail Form','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\r\n</tmpl_if>\r\n\r\n<tmpl_if error_loop>\r\n<ul>\r\n<tmpl_loop error_loop>\r\n <li><b><tmpl_var error.message></b>\r\n</tmpl_loop>\r\n</ul>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p />\r\n</tmpl_if>\r\n\r\n<tmpl_if canEdit>\r\n <a href=\"<tmpl_var entryList.url>\"><tmpl_var entryList.label></a>\r\n &middot; <a href=\"<tmpl_var export.tab.url>\"><tmpl_var export.tab.label></a>\r\n <tmpl_if entryId>\r\n &middot; <a href=\"<tmpl_var delete.url>\"><tmpl_var delete.label></a>\r\n </tmpl_if>\r\n <tmpl_if session.var.adminOn>\r\n &middot; <a href=\"<tmpl_var addField.url>\"><tmpl_var addField.label></a>\r\n &middot; <a href=\"<tmpl_var addTab.url>\"><tmpl_var addTab.label></a>\r\n </tmpl_if>\r\n <p /> \r\n</tmpl_if>\r\n\r\n<tmpl_var form.start>\r\n<table>\r\n<tmpl_loop field_loop>\r\n <tmpl_unless field.isHidden>\r\n <tr><td class=\"formDescription\" valign=\"top\">\r\n <tmpl_if session.var.adminOn><tmpl_if canEdit><tmpl_var field.controls></tmpl_if></tmpl_if>\r\n <tmpl_var field.label>\r\n </td><td class=\"tableData\" valign=\"top\">\r\n <tmpl_if field.isDisplayed>\r\n <tmpl_var field.value>\r\n <tmpl_else>\r\n <tmpl_var field.form>\r\n </tmpl_if>\r\n <tmpl_if field.required>*</tmpl_if>\r\n <span class=\"formSubtext\"><br /><tmpl_var field.subtext></span>\r\n </td></tr>\r\n </tmpl_unless>\r\n</tmpl_loop>\r\n<tr><td></td><td><tmpl_var form.send></td></tr>\r\n</table>\r\n\r\n<tmpl_var form.end>\r\n','DataForm');
INSERT INTO template VALUES (4,'Tab Form','<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\r\n</tmpl_if>\r\n\r\n<tmpl_if error_loop>\r\n <ul>\r\n <tmpl_loop error_loop>\r\n <li><b><tmpl_var error.message></b>\r\n </tmpl_loop>\r\n </ul>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <tmpl_var description><p />\r\n</tmpl_if>\r\n\r\n<tmpl_if canEdit>\r\n <a href=\"<tmpl_var entryList.url>\"><tmpl_var entryList.label></a>\r\n &middot; <a href=\"<tmpl_var export.tab.url>\"><tmpl_var export.tab.label></a>\r\n <tmpl_if entryId>\r\n &middot; <a href=\"<tmpl_var delete.url>\"><tmpl_var delete.label></a>\r\n </tmpl_if>\r\n <tmpl_if session.var.adminOn>\r\n &middot; <a href=\"<tmpl_var addField.url>\"><tmpl_var addField.label></a>\r\n &middot; <a href=\"<tmpl_var addTab.url>\"><tmpl_var addTab.label></a>\r\n </tmpl_if>\r\n<p /> \r\n</tmpl_if>\r\n<tmpl_var form.start>\r\n<link href=\"/extras/tabs/tabs.css\" rel=\"stylesheet\" rev=\"stylesheet\" type=\"text/css\">\r\n<div class=\"tabs\">\r\n <tmpl_loop tab_loop>\r\n <span onclick=\"toggleTab(<tmpl_var tab.sequence>)\" id=\"tab<tmpl_var tab.sequence>\" class=\"tab\"><tmpl_var tab.label>\r\n <tmpl_if session.var.adminOn>\r\n <tmpl_if canEdit>\r\n <tmpl_var tab.controls>\r\n </tmpl_if>\r\n </tmpl_if>\r\n </span>\r\n </tmpl_loop>\r\n</div>\r\n<tmpl_loop tab_loop>\r\n <tmpl_var tab.start>\r\n <table>\r\n <tmpl_loop tab.field_loop>\r\n <tmpl_unless tab.field.isHidden>\r\n <tr>\r\n <td class=\"formDescription\" valign=\"top\">\r\n <tmpl_if session.var.adminOn>\r\n <tmpl_if canEdit>\r\n <tmpl_var tab.field.controls>\r\n </tmpl_if>\r\n </tmpl_if>\r\n <tmpl_var tab.field.label>\r\n </td>\r\n <td class=\"tableData\" valign=\"top\">\r\n <tmpl_if tab.field.isDisplayed>\r\n <tmpl_var tab.field.value>\r\n <tmpl_else>\r\n <tmpl_var tab.field.form>\r\n </tmpl_if>\r\n <tmpl_if tab.field.isRequired>*</tmpl_if>\r\n <span class=\"formSubtext\">\r\n <br />\r\n <tmpl_var tab.field.subtext>\r\n </span>\r\n </td>\r\n </tr>\r\n </tmpl_unless>\r\n </tmpl_loop>\r\n <tr>\r\n <td colspan=\"2\">\r\n <span class=\"tabSubtext\"><tmpl_var tab.subtext></span>\r\n </td>\r\n </tr>\r\n </table>\r\n <br>\r\n <div><input type=\"submit\" value=\"save\"></div>\r\n <tmpl_var tab.end>\r\n</tmpl_loop>\r\n<tmpl_var tab.init>\r\n<tmpl_var form.end>\r\n','DataForm');
alter table groups add column isEditable int not null default 1;
alter table groups add column showInForms int not null default 1;
update groups set isEditable=0 where groupId in (1,2,7);
insert into groupings (groupId,userId) select userId, 7 from users;
insert into groupings (groupId,userId) select userId, 2 from users where userId<>1;

View file

@ -1,402 +0,0 @@
package WebGUI::Authentication;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2003 Plain Black LLC.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict qw(vars subs);
use WebGUI::ErrorHandler;
use WebGUI::Session;
use WebGUI::SQL;
=head1 NAME
Package WebGUI::Authentication
=head1 DESCRIPTION
This package is used to access WebGUI's pluggable authentication system.
=head1 SYNOPSIS
use WebGUI::Authentication;
$html = WebGUI::Authentication::adminForm($userId,$authMethod);
WebGUI::Authentication::adminFormSave($userId,$authMethod);
$error = WebGUI::Authentication::adminFormValidate($authMethod);
$result = WebGUI::Authentication::authenticate($userId,$identifier,$authMethod);
WebGUI::Authentication::deleteParams($userId);
$params = WebGUI::Authentication::getParams($userId,$authMethod);
WebGUI::Authentication::saveParams($userId,$authMethod,\%data);
$label = WebGUI::Authentication::optionsLabel($authMethod);
$html = WebGUI::Authentication::settingsForm($authMethod);
$html = WebGUI::Authentication::registrationForm();
WebGUI::Authentication::registrationFormSave($userId);
$error = WebGUI::Authentication::registrationFormValidate();
$html = WebGUI::Authentication::userForm();
WebGUI::Authentication::userFormSave();
$error = WebGUI::Authentication::userFormValidate();
=head1 METHODS
These functions are available from this package:
=cut
#-------------------------------------------------------------------
sub _execute {
my ($authMethod, $function, $params) = @_;
my $cmd = "WebGUI::Authentication::".$authMethod."::".$function;
return eval {&$cmd($params)} unless ($@);
WebGUI::ErrorHandler::fatalError("Missing method in Authentication module: $authMethod. ".$@);
}
#-------------------------------------------------------------------
=head2 adminForm ( userId, authMethod )
Returns the admin form for the specified authentication method.
=over
=item userId
This user's id.
=item authMethod
Specify the authentication method.
=back
=cut
sub adminForm {
my $userId = shift;
my $authMethod = shift;
return _execute($authMethod,"adminForm",$userId);
}
#-------------------------------------------------------------------
=head2 adminFormSave ( userId, authMethod )
Saves the specified user's authentication information to the database.
=over
=item userId
The user id to save the information for.
=item authMethod
Specify the authentication method.
=back
=cut
sub adminFormSave {
my $userId = shift;
my $authMethod = shift;
return _execute($authMethod,"adminFormSave",$userId);
}
#-------------------------------------------------------------------
=head2 adminFormValidate ( authMethod )
Returns an error string if there are any problems with the form data.
=over
=item authMethod
Specify the authentication method.
=back
=cut
sub adminFormValidate {
my $authMethod = shift;
return _execute($authMethod,"adminFormValidate");
}
#-------------------------------------------------------------------
=head2 authenticate ( userId, identifier, authMethod )
Check to see that the user supplied information is correct. Returns "1" if successful otherwise it returns an error message.
=over
=item userId
The user to authenticate.
=item identifier
The password, pass phrase, PIN, or other unique identifier to verify this user.
=item authMethod
The type of authentication to use to authenticate this user.
=back
=cut
sub authenticate {
my ($userId, $identifier, $authMethod) = @_;
return _execute($authMethod,"authenticate",[$userId,$identifier]);
}
#-------------------------------------------------------------------
=head2 deleteParams ( userId )
Removes the specified user's authentication parameters from the database for all authentication methods. This is primarily useful when deleting the user's account.
=over
=item userId
The user id for the user to have the parameters deleted.
=back
=cut
sub deleteParams {
my $uid = shift;
if ($uid) {
WebGUI::SQL->write("delete from authentication where userId=$uid");
}
}
#-------------------------------------------------------------------
=head2 getParams ( userId [ , authMethod ] )
Returns a hash reference with the user's authentication information.
=over
=item userId
Specify a user id.
=item authMethod
Optionally specify the authentication method. Defaults to the system-wide authentication method.
=back
=cut
sub getParams {
my $uid = shift;
my $authMethod = shift;
$authMethod = $session{setting}{authMethod} if ($authMethod eq "");
return WebGUI::SQL->buildHashRef("select fieldName, fieldData from authentication
where userId=$uid and authMethod='$authMethod'");
}
#-------------------------------------------------------------------
=head2 optionsLabel ( authMethod )
Returns a label that can be displayed to describe the settings for this auth method.
=over
=item authMethod
The authentication method.
=back
=cut
sub optionsLabel {
my $authMethod = shift;
return _execute($authMethod,"optionsLabel");
}
#-------------------------------------------------------------------
=head2 registrationForm ( )
Returns the user registration form for the default auth method.
=cut
sub registrationForm {
my $authMethod = $session{setting}{authMethod};
return _execute($authMethod,"registrationForm");
}
#-------------------------------------------------------------------
=head2 registrationFormSave ( userId )
Creates the appropriate values in the database for this user based upon their registration information.
=over
=item userId
The user id to store with the registration data.
=back
=cut
sub registrationFormSave {
my $authMethod = $session{setting}{authMethod};
_execute($authMethod,"registrationFormSave",$_[0]);
}
#-------------------------------------------------------------------
=head2 registrationFormValidate ( )
Returns the WebGUI username to user for this user, and returns an error string if there are any problems with the form data.
=cut
sub registrationFormValidate {
my $authMethod = $session{setting}{authMethod};
return _execute($authMethod,"registrationFormValidate");
}
#-------------------------------------------------------------------
=head2 settingsForm ( authMethod )
Returns a form for the WebGUI settings area.
=over
=item authMethod
The authentication method to display the form for.
=back
=cut
sub settingsForm {
my $authMethod = shift;
return _execute($authMethod,"settingsForm");
}
#-------------------------------------------------------------------
=head2 saveParams ( userId, authMethod, data )
Saves the user's authentication parameters to the database.
=over
=item userId
Specify a user id.
=item authMethod
Specify the authentication method to save these paramaters under.
=item data
A hash reference containing parameter names and values to be saved.
=back
=cut
sub saveParams {
my ($uid, $authMethod, $data) = @_;
foreach (keys %{$data}) {
WebGUI::SQL->write("delete from authentication where
userId=$uid and authMethod=".quote($authMethod)." and fieldName=".quote($_));
WebGUI::SQL->write("insert into authentication (userId,authMethod,fieldData,fieldName)
values ($uid,".quote($authMethod).",".quote($data->{$_}).",".quote($_).")");
}
}
#-------------------------------------------------------------------
=head2 userForm ( )
Returns the user authentication data form.
=cut
sub userForm {
my $authMethod = $session{user}{authMethod} || $session{setting}{authMethod};
return _execute($authMethod,"userForm");
}
#-------------------------------------------------------------------
=head2 userFormSave ( )
Saves user form data to the database.
=cut
sub userFormSave {
my $authMethod = $session{user}{authMethod} || $session{setting}{authMethod};
_execute($authMethod,"userFormSave");
}
#-------------------------------------------------------------------
=head2 userFormValidate ( )
Returns the WebGUI username to use for this user, and returns an error string if there are any problems with the form data.
=cut
sub userFormValidate {
my $authMethod = $session{user}{authMethod} || $session{setting}{authMethod};
return _execute($authMethod,"userFormValidate");
}
1;

View file

@ -1,195 +0,0 @@
package WebGUI::Authentication::LDAP;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Session;
use WebGUI::HTMLForm;
use WebGUI::Authentication;
use URI;
use Net::LDAP;
my %ldapStatusCode = ( 0=>'success (0)', 1=>'Operations Error (1)', 2=>'Protocol Error (2)',
3=>'Time Limit Exceeded (3)', 4=>'Size Limit Exceeded (4)', 5=>'Compare False (5)',
6=>'Compare True (6)', 7=>'Auth Method Not Supported (7)', 8=>'Strong Auth Required (8)',
9=>'Referral (10)', 11=>'Admin Limit Exceeded (11)', 12=>'Unavailable Critical Extension (12)',
13=>'Confidentiality Required (13)', 14=>'Sasl Bind In Progress (14)',
15=>'No Such Attribute (16)', 17=>'Undefined Attribute Type (17)',
18=>'Inappropriate Matching (18)', 19=>'Constraint Violation (19)',
20=>'Attribute Or Value Exists (20)', 21=>'Invalid Attribute Syntax (21)', 32=>'No Such Object (32)',
33=>'Alias Problem (33)', 34=>'Invalid DN Syntax (34)', 36=>'Alias Dereferencing Problem (36)',
48=>'Inappropriate Authentication (48)', 49=>'Invalid Credentials (49)',
50=>'Insufficient Access Rights (50)', 51=>'Busy (51)', 52=>'Unavailable (52)',
53=>'Unwilling To Perform (53)', 54=>'Loop Detect (54)', 64=>'Naming Violation (64)',
65=>'Object Class Violation (65)', 66=>'Not Allowed On Non Leaf (66)', 67=>'Not Allowed On RDN (67)',
68=>'Entry Already Exists (68)', 69=>'Object Class Mods Prohibited (69)',
71=>'Affects Multiple DSAs (71)', 80=>'other (80)');
#-------------------------------------------------------------------
sub authenticate {
my ($userId, $password, $userData, $uri, $ldap, $auth, $result);
$userId = $_[0]->[0];
my $identifier = $_[0]->[1];
$userData = WebGUI::Authentication::getParams($userId, 'LDAP');
return "No connect DN specified." if ($$userData{connectDN} eq "");
if ($uri = URI->new($userData->{ldapUrl})) {
$ldap = Net::LDAP->new($uri->host, (port=>$uri->port)) or $result = WebGUI::International::get(2,'Auth/LDAP');
return $result if $result;
$auth = $ldap->bind(dn=>$$userData{connectDN}, password=>$identifier);
if ($auth->code == 48 || $auth->code == 49) {
$result = WebGUI::International::get(68);
} elsif ($auth->code > 0) {
$result .= 'LDAP error "'.$ldapStatusCode{$auth->code}.'" occured.';
$result .= WebGUI::International::get(69);
WebGUI::ErrorHandler::warn("LDAP error: ".$ldapStatusCode{$auth->code});
} else {
$result = 1;
}
$ldap->unbind;
} else {
$result = "Invalid LDAP connection URL. Contact your administrator.";
WebGUI::ErrorHandler::warn("Could not process this LDAP URL: ".$userData->{ldapUrl});
}
return $result;
}
#-------------------------------------------------------------------
sub adminForm {
my $userData = WebGUI::Authentication::getParams($_[0],'LDAP');
my $ldapUrl = $session{form}{'authLDAP.ldapUrl'} || $userData->{ldapUrl} || $session{setting}{ldapURL};
my $connectDN = $session{form}{'authLDAP.connectDN'} || $userData->{connectDN};
my $f;
$f = WebGUI::HTMLForm->new;
$f->readOnly('<b>'.optionsLabel().'</b>');
$f->url("authLDAP.ldapUrl",WebGUI::International::get(3,'Auth/LDAP'),$ldapUrl);
$f->text("authLDAP.connectDN",WebGUI::International::get(4,'Auth/LDAP'),$connectDN);
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub adminFormSave {
WebGUI::Authentication::saveParams($_[0],'LDAP',
{
connectDN => $session{form}{'authLDAP.connectDN'},
ldapUrl => $session{form}{'authLDAP.ldapUrl'}
});
}
#-------------------------------------------------------------------
sub adminFormValidate {
return "";
}
#-------------------------------------------------------------------
sub optionsLabel {
return WebGUI::International::get(1,'Auth/LDAP');
}
#-------------------------------------------------------------------
sub registrationForm {
my $f;
$f = WebGUI::HTMLForm->new;
$f->text("authLDAP.ldapId",$session{setting}{ldapIdName},$session{form}{"authLDAP.ldapId"});
$f->password("authLDAP.ldapPassword",$session{setting}{ldapPasswordName});
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub registrationFormSave {
my ($auth, $connectDN);
my $uid = shift;
my $uri = URI->new($session{setting}{ldapURL});
my $ldap = Net::LDAP->new($uri->host, (port=>$uri->port));
$ldap->bind;
my $search = $ldap->search (base => $uri->dn, filter => $session{setting}{ldapId}."=".$session{form}{'authLDAP.ldapId'});
if (defined $search->entry(0)) {
if ($session{setting}{ldapUserRDN} eq 'dn') {
$connectDN = $search->entry(0)->dn;
} else {
$connectDN = $search->entry(0)->get_value($session{setting}{ldapUserRDN});
}
}
$ldap->unbind;
WebGUI::Authentication::saveParams($uid,'LDAP', {
connectDN => $connectDN,
ldapUrl => $session{setting}{ldapURL}
});
}
#-------------------------------------------------------------------
sub registrationFormValidate {
my ($uri, $error, $ldap, $search, $auth, $connectDN);
$uri = URI->new($session{setting}{ldapURL});
if ($ldap = Net::LDAP->new($uri->host, (port=>$uri->port))) {
if ($ldap->bind) {
$search = $ldap->search (base=>$uri->dn,filter=>$session{setting}{ldapId}."=".$session{form}{'authLDAP.ldapId'});
if (defined $search->entry(0)) {
if ($session{setting}{ldapUserRDN} eq 'dn') {
$connectDN = $search->entry(0)->dn;
} else {
$connectDN = $search->entry(0)->get_value($session{setting}{ldapUserRDN});
}
$ldap->unbind;
$ldap = Net::LDAP->new($uri->host, (port=>$uri->port)) or $error .= WebGUI::International::get(2,'Auth/LDAP');
$auth = $ldap->bind(dn=>$connectDN, password=>$session{form}{'authLDAP.ldapPassword'});
if ($auth->code == 48 || $auth->code == 49) {
$error .= '<li>'.WebGUI::International::get(68);
WebGUI::ErrorHandler::warn("Invalid LDAP information for registration of LDAP ID: ".$session{form}{'authLDAP.ldapId'});
} elsif ($auth->code > 0) {
$error .= '<li>LDAP error "'.$ldapStatusCode{$auth->code}.'" occured. '
.WebGUI::International::get(69);
WebGUI::ErrorHandler::warn("LDAP error: ".$ldapStatusCode{$auth->code});
}
$ldap->unbind;
} else {
$error .= '<li>'.WebGUI::International::get(68);
WebGUI::ErrorHandler::warn("Invalid LDAP information for registration of LDAP ID: ".$session{form}{'authLDAP.ldapId'});
}
} else {
$error = WebGUI::International::get(2,'Auth/LDAP');
WebGUI::ErrorHandler::warn("Couldn't bind to LDAP server: ".$session{setting}{ldapURL});
}
} else {
$error = WebGUI::International::get(2,'Auth/LDAP');
WebGUI::ErrorHandler::warn("Couldn't create LDAP object: ".$uri->host);
}
return ($session{form}{'authLDAP.ldapId'},$error);
}
#-------------------------------------------------------------------
sub settingsForm {
my $f;
$f = WebGUI::HTMLForm->new;
$f->readOnly('<b>'.optionsLabel().'</b>');
$f->url("ldapUserRDN",WebGUI::International::get(9,'Auth/LDAP'),$session{setting}{ldapUserRDN});
$f->url("ldapURL",WebGUI::International::get(5,'Auth/LDAP'),$session{setting}{ldapURL});
$f->text("ldapId",WebGUI::International::get(6,'Auth/LDAP'),$session{setting}{ldapId});
$f->text("ldapIdName",WebGUI::International::get(7,'Auth/LDAP'),$session{setting}{ldapIdName});
$f->text("ldapPasswordName",WebGUI::International::get(8,'Auth/LDAP'),$session{setting}{ldapPasswordName});
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub userForm {
return undef;
}
#-------------------------------------------------------------------
sub userFormSave {
}
#-------------------------------------------------------------------
sub userFormValidate {
return ($session{user}{username},"");
}
1;

View file

@ -1,137 +0,0 @@
package WebGUI::Authentication::SMB;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2002 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------~
use strict;
use WebGUI::Session;
use WebGUI::HTMLForm;
use WebGUI::Authentication;
use Authen::Smb;
use warnings;
my %smbError = (
1 => WebGUI::International::get(2,'Auth/SMB'),
2 => WebGUI::International::get(3,'Auth/SMB'),
3 => WebGUI::International::get(4,'Auth/SMB')
);
#-------------------------------------------------------------------
sub authenticate {
my ($userId, $password, $userData, $smb, $result);
$userId = $_[0]->[0];
$password = $_[0]->[1];
$userData = WebGUI::Authentication::getParams($userId, 'SMB');
return "<li>No SMB username specfified." unless ($userData->{smbLogin});
$smb = Authen::Smb::authen($userData->{smbLogin}, $password, $userData->{smbPDC}, $userData->{smbBDC}, $userData->{smbDomain});
if ($smb > 0) {
return '<li>'. $smbError{$smb};
} else {
return 1;
}
}
#-------------------------------------------------------------------
sub adminForm {
my $userData = WebGUI::Authentication::getParams($_[0], 'SMB');
my $pdc = $session{form}{'authSMB.smbPDC'} || $userData->{smbPDC} || $session{setting}{smbPDC};
my $bdc = $session{form}{'authSMB.smbBDC'} || $userData->{smbBDC} || $session{setting}{smbBDC};
my $domain = $session{form}{'authSMB.smbDomain'} || $userData->{smbDomain} || $session{setting}{smbDomain};
my $login = $session{form}{'authSMB.smbLogin'} || $userData->{smbLogin};
my $f;
$f = WebGUI::HTMLForm->new;
$f->readOnly('<b>'.optionsLabel().'</b>');
$f->text("authSMB.smbPDC",WebGUI::International::get(5,'Auth/SMB'),$pdc);
$f->text("authSMB.smbBDC",WebGUI::International::get(6,'Auth/SMB'),$bdc);
$f->text("authSMB.smbDomain",WebGUI::International::get(7,'Auth/SMB'),$domain);
$f->text("authSMB.smbLogin",WebGUI::International::get(8,'Auth/SMB'),$login);
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub adminFormSave {
WebGUI::Authentication::saveParams($session{form}{uid},'SMB',
{
smbPDC => $session{form}{'authSMB.smbPDC'},
smbBDC => $session{form}{'authSMB.smbBDC'},
smbDomain => $session{form}{'authSMB.smbDomain'},
smbLogin => $session{form}{'authSMB.smbLogin'}
});
}
#-------------------------------------------------------------------
sub optionsLabel {
return WebGUI::International::get(1,'Auth/SMB');
}
#-------------------------------------------------------------------
sub registrationForm {
my $f;
$f = WebGUI::HTMLForm->new;
$f->text("authSMB.loginId",WebGUI::International::get(8,'Auth/SMB'));
$f->password("authSMB.smbPassword",WebGUI::International::get(9,'Auth/SMB'));
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub registrationFormSave {
my $uid;
$uid = shift;
WebGUI::Authentication::saveParams($uid,'SMB',
{
smbPDC => $session{setting}{smbPDC},
smbBDC => $session{setting}{smbBDC},
smbDomain => $session{setting}{smbDomain},
smbLogin => $session{form}{'authSMB.loginId'}
});
}
#-------------------------------------------------------------------
sub registrationFormValidate {
my ($pdc, $bdc, $ntDomain, $smbLogin, $smb, $error);
$pdc = $session{setting}{smbPDC};
$bdc = $session{setting}{smbBDC};
$ntDomain = $session{setting}{smbDomain};
$smbLogin = $session{form}{'authSMB.loginId'};
$smb = Authen::Smb::authen($smbLogin, $session{form}{'authSMB.smbPassword'}, $pdc, $bdc, $ntDomain);
if ($smb > 0) {
$error = '<li>'. $smbError{$smb} . "pdc: $pdc, bdc: $bdc, domain: $ntDomain";
}
return ($session{form}{'authSMB.loginId'}, $error);
}
#-------------------------------------------------------------------
sub settingsForm {
my $f;
$f = WebGUI::HTMLForm->new;
$f->readOnly('<b>'.optionsLabel().'</b>');
$f->text("smbPDC",WebGUI::International::get(5,'Auth/SMB'),$session{setting}{smbPDC});
$f->text("smbBDC",WebGUI::International::get(6,'Auth/SMB'),$session{setting}{smbBDC});
$f->text("smbDomain",WebGUI::International::get(7,'Auth/SMB'),$session{setting}{smbDomain});
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub userForm {
return undef;
}
#-------------------------------------------------------------------
sub userFormSave {
}
#-------------------------------------------------------------------
sub userFormValidate {
return ($session{user}{username},"");
}
1;

View file

@ -1,163 +0,0 @@
package WebGUI::Authentication::WebGUI;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use Digest::MD5;
use strict;
use WebGUI::Session;
use WebGUI::Authentication;
use WebGUI::HTMLForm;
#-------------------------------------------------------------------
sub authenticate {
my ($userId, $identifier, $userData, $success);
$userId = $_[0]->[0];
$identifier = $_[0]->[1];
$userData = WebGUI::Authentication::getParams($userId, 'WebGUI');
if ((Digest::MD5::md5_base64($identifier) eq $$userData{identifier}) && ($identifier ne "")) {
$success = 1;
} else {
$success = WebGUI::International::get(68);
}
return $success;
}
#-------------------------------------------------------------------
sub adminForm {
my $f;
$f = WebGUI::HTMLForm->new;
$f->readOnly('<b>'.optionsLabel().'</b>');
$f->password("authWebGUI.identifier",WebGUI::International::get(51),"password");
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub adminFormSave {
unless ($session{form}{'authWebGUI.identifier'} eq "password") {
WebGUI::Authentication::saveParams($_[0],'WebGUI',{identifier => Digest::MD5::md5_base64($session{form}{'authWebGUI.identifier'})});
}
}
#-------------------------------------------------------------------
sub adminFormValidate {
return "";
}
#-------------------------------------------------------------------
sub optionsLabel {
return WebGUI::International::get(1,'Auth/WebGUI');
}
#-------------------------------------------------------------------
sub registrationForm {
my $f;
$f = WebGUI::HTMLForm->new;
$f->text("authWebGUI.username",WebGUI::International::get(50),$session{form}{"authWebGUI.username"});
$f->password("authWebGUI.identifier",WebGUI::International::get(51));
$f->password("authWebGUI.identifierConfirm",WebGUI::International::get(2,'Auth/WebGUI'));
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub registrationFormSave {
my $authInfo = "\n\n".WebGUI::International::get(50).": ".$session{form}{"authWebGUI.username"}."\n"
.WebGUI::International::get(51).": ".$session{form}{'authWebGUI.identifier'}."\n\n";
adminFormSave($_[0]);
WebGUI::MessageLog::addEntry($_[0],"",WebGUI::International::get(870),$session{setting}{welcomeMessage}.$authInfo) if ($session{setting}{sendWelcomeMessage});
}
#-------------------------------------------------------------------
sub registrationFormValidate {
my ($error);
if ($session{form}{"authWebGUI.username"} =~ /^\s/ || $session{form}{"authWebGUI.username"} =~ /\s$/) {
$error = '<li>'.WebGUI::International::get(724);
}
if ($session{form}{"authWebGUI.username"} eq "") {
$error .= '<li>'.WebGUI::International::get(725);
}
unless ($session{form}{"authWebGUI.username"} =~ /^[A-Za-z0-9\-\_\.\,\@]+$/) {
$error .= '<li>'.WebGUI::International::get(747);
}
if ($session{form}{'authWebGUI.identifier'} ne $session{form}{'authWebGUI.identifierConfirm'}) {
$error .= '<li>'.WebGUI::International::get(3,'Auth/WebGUI');
}
if ($session{form}{'authWebGUI.identifier'} eq "password") {
$error .= '<li>'.WebGUI::International::get(5,'Auth/WebGUI');
}
if ($session{form}{'authWebGUI.identifier'} eq "") {
$error .= '<li>'.WebGUI::International::get(4,'Auth/WebGUI');
}
return ($session{form}{"authWebGUI.username"},$error);
}
#-------------------------------------------------------------------
sub settingsForm {
my $f = WebGUI::HTMLForm->new;
$f->readOnly('<b>'.optionsLabel().'</b>');
$f->yesNo(
-name=>"sendWelcomeMessage",
-value=>$session{setting}{sendWelcomeMessage},
-label=>WebGUI::International::get(868)
);
$f->textarea(
-name=>"welcomeMessage",
-value=>$session{setting}{welcomeMessage},
-label=>WebGUI::International::get(869)
);
$f->textarea("recoverPasswordEmail",WebGUI::International::get(134),$session{setting}{recoverPasswordEmail});
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub userForm {
my $f;
$f = WebGUI::HTMLForm->new;
$f->text("authWebGUI.username",WebGUI::International::get(50),$session{user}{username});
$f->password("authWebGUI.identifier",WebGUI::International::get(51),"password");
$f->password("authWebGUI.identifierConfirm",WebGUI::International::get(2,'Auth/WebGUI'),"password");
return $f->printRowsOnly;
}
#-------------------------------------------------------------------
sub userFormSave {
adminFormSave($session{user}{userId});
}
#-------------------------------------------------------------------
sub userFormValidate {
my ($error);
# the grandfather clause
my ($currentUsername) = WebGUI::SQL->quickArray("select username from users where userId=".$session{user}{userId});
unless ($currentUsername eq $session{form}{"authWebGUI.username"}) {
if ($session{form}{"authWebGUI.username"} =~ /^\s/ || $session{form}{"authWebGUI.username"} =~ /\s$/) {
$error = '<li>'.WebGUI::International::get(724);
}
if ($session{form}{"authWebGUI.username"} eq "") {
$error .= '<li>'.WebGUI::International::get(725);
}
unless ($session{form}{"authWebGUI.username"} =~ /^[A-Za-z0-9\-\_\.\,\@]+$/) {
$error .= '<li>'.WebGUI::International::get(747);
}
}
if ($session{form}{'authWebGUI.identifier'} ne $session{form}{'authWebGUI.identifierConfirm'}) {
$error = '<li>'.WebGUI::International::get(3,'Auth/WebGUI');
}
if ($session{form}{'authWebGUI.identifier'} eq "") {
$error .= '<li>'.WebGUI::International::get(4,'Auth/WebGUI');
}
return ($session{form}{"authWebGUI.username"},$error);
}
1;

View file

@ -832,9 +832,9 @@ sub group {
tie %hash, 'Tie::IxHash';
my $exclude = $_[0]->{excludeGroups};
if ($$exclude[0] ne "") {
$where = "where groupId not in (".join(",",@$exclude).")";
$where = "and groupId not in (".join(",",@$exclude).")";
}
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups $where order by groupName");
%hash = WebGUI::SQL->buildHash("select groupId,groupName from groups where showInForms=1 $where order by groupName");
return selectList({
options=>\%hash,
name=>$_[0]->{name},

View file

@ -35,8 +35,8 @@ This package provides an object-oriented way of managing WebGUI groups and group
$g = WebGUI::Group->new(3); or $g = WebGUI::User->new("new");
$g = WebGUI::Group->find("Registered Users");
$integer = $g->autoAdd;
$integer = $g->autoDelete;
$boolean = $g->autoAdd(1);
$boolean = $g->autoDelete(1);
$epoch = $g->dateCreated;
$integer = $g->deleteOffset(14);
$text = $g->description("Those really smart dudes.");
@ -45,11 +45,14 @@ This package provides an object-oriented way of managing WebGUI groups and group
$integer = $g->expireNotifyOffset(-14);
$integer = $g->expireOffset(360000);
$integer = $g->groupId;
$boolean = $g->isEditable(1);
$integer = $g->karmaThreshold(5000);
$string = $g->ipFilter("10.;192.168.1.");
$epoch = $g->lastUpdated;
$string = $g->name("Nerds");
$string = $g->scratchFilter("www_location=International;somesetting=1");
$boolean = $g->showInForms(1);
$g->addGroups(\@arr);
$g->deleteGroups(\@arr);
@ -464,6 +467,35 @@ sub ipFilter {
}
#-------------------------------------------------------------------
=head2 isEditable ( [ value ] )
Returns a boolean value indicating whether the group should be managable from the group manager. System level groups and groups autocreated by wobjects would use this parameter.
=over
=item value
If specified, isEditable is set to this value.
=back
=cut
sub isEditable {
my ($class, $value);
$class = shift;
$value = shift;
if (defined $value) {
$class->{_group}{"isEditable"} = $value;
WebGUI::SQL->write("update groups set isEditable=".quote($value).",
lastUpdated=".time()." where groupId=$class->{_groupId}");
}
return $class->{_group}{"isEditable"};
}
#-------------------------------------------------------------------
=head2 lastUpdated ( )
@ -573,6 +605,37 @@ sub scratchFilter {
#-------------------------------------------------------------------
=head2 showInForms ( [ value ] )
Returns a boolean value indicating whether the group should show in forms that display a list of groups. System level groups and groups autocreated by wobjects would use this parameter.
=over
=item value
If specified, showInForms is set to this value.
=back
=cut
sub showInForms {
my ($class, $value);
$class = shift;
$value = shift;
if (defined $value) {
$class->{_group}{"showInForms"} = $value;
WebGUI::SQL->write("update groups set showInForms=".quote($value).",
lastUpdated=".time()." where groupId=$class->{_groupId}");
}
return $class->{_group}{"showInForms"};
}
#-------------------------------------------------------------------
=head2 lastUpdated ( )
=head2 dbQuery ( [ value ] )
Returns the dbQuery for this group.

View file

@ -471,7 +471,7 @@ Generates an icon that looks like a wobject. It's purpose is to represent whethe
=cut
sub wobjectIcon {
return '<img src="'.$session{config}{extrasURL}.'/toolbar/'.$session{language}{toolbar}.'/wobject.gif" align="middle" border="0" alt="Wobject Settings" title="Wobject Settings" />';
return '<img class="dragTrigger" src="'.$session{config}{extrasURL}.'/toolbar/'.$session{language}{toolbar}.'/wobject.gif" align="middle" border="0" alt="Wobject Settings" title="Wobject Settings" />';
}

View file

@ -302,7 +302,7 @@ sub www_listGroups {
$output = helpIcon(10);
$output .= '<h1>'.WebGUI::International::get(89).'</h1>';
$sth = WebGUI::SQL->read("select groupId,groupName,description from groups
where groupId<>1 and groupId<>2 and groupId<>7 order by groupName");
where isEditable=1 order by groupName");
while (@data = $sth->array) {
$row[$i] = '<tr>';
$row[$i] .= '<td valign="top" class="tableData"><a href="'

View file

@ -55,15 +55,15 @@ sub _recursivelyChangeProperties {
$page->walk_down({
callback => sub {
if (WebGUI::Privilege::canEditPage($_[0]->get('pageId'))) {
$_[0]->setWithoutRecache({
if (WebGUI::Privilege::canEditPage($page->get('pageId'))) {
$page->setWithoutRecache({
startDate => WebGUI::FormProcessor::dateTime("startDate"),
endDate => WebGUI::FormProcessor::dateTime("endDate"),
ownerId => $session{form}{ownerId},
groupIdView => $session{form}{groupIdView},
groupIdEdit => $session{form}{groupIdEdit}
}) if ($session{form}{recursePrivs});
$_[0]->setWithoutRecache({
$page->setWithoutRecache({
styleId => $session{form}{styleId}
}) if ($session{form}{recurseStyle});
}
@ -74,7 +74,7 @@ sub _recursivelyChangeProperties {
WebGUI::Page->recachePageTree;
}
-------------------------------------------------------------------
#-------------------------------------------------------------------
sub _reorderPages {
my ($sth, $i, $pid);
$sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0] order by sequenceNumber");

View file

@ -278,6 +278,7 @@ sub generate {
.moveUpIcon('op=movePageUp')
.moveDownIcon('op=movePageDown')
.cutIcon('op=cutPage');
my @wobjectsinpage;
my $sth = WebGUI::SQL->read("select * from wobject where pageId=".$session{page}{pageId}." order by sequenceNumber, wobjectId");
while (my $wobject = $sth->hashRef) {
my $wobjectToolbar = wobjectIcon()
@ -330,8 +331,10 @@ sub generate {
'wobject.content'=>eval{$w->www_view}
});
WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace}. Root cause: ".$@) if($@);
push(@wobjectsinpage,{'wobject.id'=>${$wobject}{wobjectId}});
}
$sth->finish;
$var{"wobjectid_list"} = \@wobjectsinpage;
return WebGUI::Template::process(getTemplate(),\%var);
}

View file

@ -262,11 +262,12 @@ sub isInGroup {
my ($gid, $uid, @data, %group, $groupId);
($gid, $uid) = @_;
$uid = $session{user}{userId} if ($uid eq "");
### The "Everyone" group automatically returns true.
#The next 3 checks are to increase performance. If this section were removed, everything would continue to work as normal.
if ($gid == 7) {
return 1;
}
### The "Visitor" group returns false, unless the user is visitor.
if ($gid == 1) {
if ($uid == 1) {
return 1;
@ -274,10 +275,12 @@ sub isInGroup {
return 0;
}
}
### The "Registered Users" group returns true if user is not visitor.
if ($gid==2 && $uid != 1) {
return 1;
}
### Use session to cache multiple lookups of the same group.
if ($session{isInGroup}{$gid}{$uid} || $session{isInGroup}{3}{$uid}) {
return 1;

View file

@ -1,136 +0,0 @@
package WebGUI::Wobject::ExtraColumn;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use Tie::IxHash;
use WebGUI::DateTime;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Page;
use WebGUI::TabForm;
use WebGUI::Template;
use WebGUI::Wobject;
our @ISA = qw(WebGUI::Wobject);
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(1,$_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $property = shift;
my $self = WebGUI::Wobject->new(
-properties=>$property,
-extendedProperties=>{
spacer=>{
defaultValue=>10
},
width=>{
defaultValue=>200
},
class=>{
defaultValue=>"content"
}
}
);
bless $self, $class;
}
#-------------------------------------------------------------------
sub uiLevel {
return 1;
}
#-------------------------------------------------------------------
sub www_edit {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
my ($output, $f);
$output = helpIcon(1,$_[0]->get("namespace"));
$output .= '<h1>'.WebGUI::International::get(6,$_[0]->get("namespace")).'</h1>';
my %tabs;
tie %tabs, 'Tie::IxHash';
%tabs = (
properties=>{
label=>WebGUI::International::get(893)
},
layout=>{
label=>WebGUI::International::get(105),
uiLevel=>5
},
privileges=>{
label=>WebGUI::International::get(107),
uiLevel=>9
}
);
$f = WebGUI::TabForm->new(\%tabs);
$f->hidden({name=>"wid",value=>$_[0]->get("wobjectId")});
$f->hidden({name=>"namespace",value=>$_[0]->get("namespace")}) if ($_[0]->get("wobjectId") eq "new");
$f->hidden({name=>"func",value=>"editSave"});
$f->getTab("properties")->readOnly(
-value=>$_[0]->get("wobjectId"),
-label=>WebGUI::International::get(499)
);
$f->hidden({name=>"title",value=>$_[0]->name});
$f->hidden({name=>"displayTitle",value=>$_[0]->getValue("displayTitle")});
$f->getTab("layout")->select(
-name=>"templatePosition",
-label=>WebGUI::International::get(363),
-value=>[$_[0]->getValue("templatePosition")],
-uiLevel=>5,
-options=>WebGUI::Page::getTemplatePositions($session{page}{templateId}),
-subtext=>WebGUI::Page::drawTemplate($session{page}{templateId})
);
$f->getTab("privileges")->dateTime(
-name=>"startDate",
-label=>WebGUI::International::get(497),
-value=>$_[0]->getValue("startDate")
);
$f->getTab("privileges")->dateTime(
-name=>"endDate",
-label=>WebGUI::International::get(498),
-value=>$_[0]->getValue("endDate")
);
$f->getTab("properties")->integer(
-name=>"spacer",
-label=>WebGUI::International::get(3,$_[0]->get("namespace")),
-value=>,$_[0]->getValue("spacer")
);
$f->getTab("properties")->integer(
-name=>"width",
-label=>WebGUI::International::get(4,$_[0]->get("namespace")),
-value=>$_[0]->getValue("width")
);
$f->getTab("properties")->text(
-name=>"class",
-label=>WebGUI::International::get(5,$_[0]->get("namespace")),
-value=>$_[0]->getValue("class")
);
$output .= $f->print;
return $output;
}
#-------------------------------------------------------------------
sub www_view {
return '</td><td width="'.$_[0]->get("spacer").'"></td><td width="'.$_[0]->get("width").'" class="'.$_[0]->get("class").'" valign="top">';
}
1;

View file

@ -1,196 +0,0 @@
package WebGUI::Wobject::FAQ;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::HTMLForm;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Wobject;
our @ISA = qw(WebGUI::Wobject);
#-------------------------------------------------------------------
sub duplicate {
my ($w, %data, $newQuestionId, $sth);
tie %data, 'Tie::CPHash';
$w = $_[0]->SUPER::duplicate($_[1]);
$sth = WebGUI::SQL->read("select * from FAQ_question where wobjectId=".$_[0]->get("wobjectId"));
while (%data = $sth->hash) {
$newQuestionId = getNextId("FAQ_questionId");
WebGUI::SQL->write("insert into FAQ_question values (".$w.", $newQuestionId, "
.quote($data{question}).", ".quote($data{answer}).", $data{sequenceNumber})");
}
$sth->finish;
}
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(2,$_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $property = shift;
my $self = WebGUI::Wobject->new(
-properties=>$property,
-extendedProperties=>{},
-useTemplate=>1
);
bless $self, $class;
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from FAQ_question where wobjectId=".$_[0]->get("wobjectId"));
$_[0]->SUPER::purge();
}
#-------------------------------------------------------------------
sub www_deleteQuestion {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
return $_[0]->confirm(WebGUI::International::get(7,$_[0]->get("namespace")),
WebGUI::URL::page('func=deleteQuestionConfirm&wid='.$_[0]->get("wobjectId").'&qid='.$session{form}{qid}));
}
#-------------------------------------------------------------------
sub www_deleteQuestionConfirm {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->deleteCollateral("FAQ_question","FAQ_questionId",$session{form}{qid});
$_[0]->reorderCollateral("FAQ_question","FAQ_questionId");
return "";
}
#-------------------------------------------------------------------
sub www_edit {
my $properties = WebGUI::HTMLForm->new;
if ($_[0]->get("wobjectId") eq "new") {
$properties->whatNext(
-options=>{
addQuestion=>WebGUI::International::get(75,$_[0]->get("namespace")),
backToPage=>WebGUI::International::get(745)
},
-value=>"addQuestion"
);
}
return $_[0]->SUPER::www_edit(
-properties=>$properties->printRowsOnly,
-headingId=>8,
-helpId=>1
);
}
#-------------------------------------------------------------------
sub www_editSave {
$_[0]->SUPER::www_editSave();
if ($session{form}{proceed} eq "addQuestion") {
$session{form}{qid} = "new";
return $_[0]->www_editQuestion();
}
}
#-------------------------------------------------------------------
sub www_editQuestion {
my ($output, $question, $f);
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$question = $_[0]->getCollateral("FAQ_question","FAQ_questionId",$session{form}{qid});
$output = helpIcon(2,$_[0]->get("namespace"));
$output .= '<h1>'.WebGUI::International::get(10,$_[0]->get("namespace")).'</h1>';
$f = WebGUI::HTMLForm->new;
$f->hidden("wid",$_[0]->get("wobjectId"));
$f->hidden("qid",$question->{FAQ_questionId});
$f->hidden("func","editQuestionSave");
$f->textarea(
-name=>"question",
-label=>WebGUI::International::get(5,$_[0]->get("namespace")),
-value=>$question->{question}
);
$f->HTMLArea(
-name=>"answer",
-label=>WebGUI::International::get(6,$_[0]->get("namespace")),
-value=>$question->{answer}
);
if ($question->{FAQ_questionId} eq "new") {
$f->whatNext(
-options=>{
addQuestion=>WebGUI::International::get(75,$_[0]->get("namespace")),
backToPage=>WebGUI::International::get(745)
},
-value=>"backToPage"
);
}
$f->submit;
$output .= $f->print;
return $output;
}
#-------------------------------------------------------------------
sub www_editQuestionSave {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->setCollateral("FAQ_question", "FAQ_questionId", {
FAQ_questionId => $session{form}{qid},
question => $session{form}{question},
answer => $session{form}{answer}
});
if ($session{form}{proceed} eq "addQuestion") {
$session{form}{qid} = "new";
return $_[0]->www_editQuestion();
}
return "";
}
#-------------------------------------------------------------------
sub www_moveQuestionDown {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->moveCollateralDown("FAQ_question","FAQ_questionId",$session{form}{qid});
return "";
}
#-------------------------------------------------------------------
sub www_moveQuestionUp {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->moveCollateralUp("FAQ_question","FAQ_questionId",$session{form}{qid});
return "";
}
#-------------------------------------------------------------------
sub www_view {
my (%question, $controls, $sth, %var, @qa);
tie %question,'Tie::CPHash';
$var{"addquestion.url"} = WebGUI::URL::page('func=editQuestion&wid='.$_[0]->get("wobjectId"));
$var{"addquestion.label"} = WebGUI::International::get(9,$_[0]->get("namespace"));
$sth = WebGUI::SQL->read("select * from FAQ_question where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
while (%question = $sth->hash) {
$controls = deleteIcon('func=deleteQuestion&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId})
.editIcon('func=editQuestion&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId})
.moveUpIcon('func=moveQuestionUp&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId})
.moveDownIcon('func=moveQuestionDown&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId});
push(@qa,{
"qa.Id"=>$question{FAQ_questionId},
"qa.answer"=>$question{answer},
"qa.question"=>$question{question},
"qa.controls"=>$controls
});
}
$sth->finish;
$var{qa_loop} = \@qa;
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
}
1;

View file

@ -1,97 +0,0 @@
package WebGUI::Wobject::Item;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::Attachment;
use WebGUI::HTMLForm;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Utility;
use WebGUI::Wobject;
our @ISA = qw(WebGUI::Wobject);
#-------------------------------------------------------------------
sub duplicate {
my ($w, $f);
$w = $_[0]->SUPER::duplicate($_[1]);
$f = WebGUI::Attachment->new($_[0]->get("attachment"),$_[0]->get("wobjectId"));
$f->copy($w);
}
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(4,$_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $property = shift;
my $self = WebGUI::Wobject->new(
-properties=>$property,
-extendedProperties=>{
linkURL=>{},
attachment=>{}
},
-useTemplate=>1
);
bless $self, $class;
}
#-------------------------------------------------------------------
sub www_edit {
my $properties = WebGUI::HTMLForm->new;
$properties->url(
-name=>"linkURL",
-label=>WebGUI::International::get(1,$_[0]->get("namespace")),
-value=>$_[0]->getValue("linkURL"));
$properties->raw($_[0]->fileProperty("attachment",2));
return $_[0]->SUPER::www_edit(
-properties=>$properties->printRowsOnly,
-headingId=>6,
-helpId=>1
);
}
#-------------------------------------------------------------------
sub www_editSave {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
my ($attachment, $property);
$_[0]->SUPER::www_editSave() if ($_[0]->get("wobjectId") eq "new");
$attachment = WebGUI::Attachment->new("",$_[0]->get("wobjectId"));
$attachment->save("attachment");
$property->{attachment} = $attachment->getFilename if ($attachment->getFilename ne "");
$_[0]->SUPER::www_editSave($property);
return "";
}
#-------------------------------------------------------------------
sub www_view {
my ($file, %var);
if ($_[0]->get("attachment") ne "") {
$file = WebGUI::Attachment->new($_[0]->get("attachment"),$_[0]->get("wobjectId"));
$var{"attachment.name"} = $file->getFilename;
$var{"attachment.URL"} = $file->getURL;
$var{"attachment.Icon"} = $file->getIcon;
}
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
}
1;

View file

@ -1,207 +0,0 @@
package WebGUI::Wobject::LinkList;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::HTMLForm;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Wobject;
our @ISA = qw(WebGUI::Wobject);
#-------------------------------------------------------------------
sub duplicate {
my ($w, $sth, $row);
$w = $_[0]->SUPER::duplicate($_[1]);
$w = WebGUI::Wobject::LinkList->new({wobjectId=>$w,namespace=>$_[0]->get("namespace")});
$sth = WebGUI::SQL->read("select * from LinkList_link where wobjectId=".$_[0]->get("wobjectId")
." order by sequenceNumber");
while ($row = $sth->hashRef) {
$row->{LinkList_linkId} = "new";
$w->setCollateral("LinkList_link","LinkList_linkId",$row);
}
$sth->finish;
}
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(6,$_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $property = shift;
my $self = WebGUI::Wobject->new(
-properties=>$property,
-extendedProperties=>{},
-useTemplate=>1,
);
bless $self, $class;
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from LinkList_link where wobjectId=".$_[0]->get("wobjectId"));
$_[0]->SUPER::purge();
}
#-------------------------------------------------------------------
sub www_deleteLink {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
return $_[0]->confirm(WebGUI::International::get(9,$_[0]->get("namespace")),
WebGUI::URL::page('func=deleteLinkConfirm&wid='.$session{form}{wid}.'&lid='.$session{form}{lid}));
}
#-------------------------------------------------------------------
sub www_deleteLinkConfirm {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->deleteCollateral("LinkList_link","LinkList_linkId",$session{form}{lid});
$_[0]->reorderCollateral("LinkList_link","LinkList_linkId");
return "";
}
#-------------------------------------------------------------------
sub www_edit {
my $properties = WebGUI::HTMLForm->new;
if ($_[0]->get("wobjectId") eq "new") {
$properties->whatNext(
-options=>{
addLink=>WebGUI::International::get(13,$_[0]->get("namespace")),
backToPage=>WebGUI::International::get(745)
},
-value=>"addLink"
);
}
return $_[0]->SUPER::www_edit(
-properties=>$properties->printRowsOnly,
-headingId=>10,
-helpId=>1
);
}
#-------------------------------------------------------------------
sub www_editSave {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->SUPER::www_editSave();
if ($session{form}{proceed} eq "addLink") {
$session{form}{lid} = "new";
$_[0]->www_editLink();
} else {
return "";
}
}
#-------------------------------------------------------------------
sub www_editLink {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
my ($output, $link, $f, $linkId, $newWindow);
$link = $_[0]->getCollateral("LinkList_link", "LinkList_linkId",$session{form}{lid});
if ($link->{LinkList_linkId} eq "new") {
$newWindow = 1;
} else {
$newWindow = $link->{newWindow};
}
$output = helpIcon(2,$_[0]->get("namespace"));
$output .= '<h1>'.WebGUI::International::get(12,$_[0]->get("namespace")).'</h1>';
$f = WebGUI::HTMLForm->new;
$f->hidden("wid",$_[0]->get("wobjectId"));
$f->hidden("lid",$link->{LinkList_linkId});
$f->hidden("func","editLinkSave");
$f->text("name",WebGUI::International::get(99),$link->{name});
$f->url("url",WebGUI::International::get(8,$_[0]->get("namespace")),$link->{url});
$f->yesNo("newWindow",WebGUI::International::get(3,$_[0]->get("namespace")),$newWindow);
$f->textarea("description",WebGUI::International::get(85),$link->{description});
if ($link->{LinkList_linkId} eq "new") {
$f->hidden("sequenceNumber",-1);
$f->whatNext(
-options=>{
addLink=>WebGUI::International::get(13,$_[0]->get("namespace")),
backToPage=>WebGUI::International::get(745)
},
-value=>"backToPage"
);
}
$f->submit;
$output .= $f->print;
return $output;
}
#-------------------------------------------------------------------
sub www_editLinkSave {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->setCollateral("LinkList_link", "LinkList_linkId", {
LinkList_linkId => $session{form}{lid},
description => $session{form}{description},
newWindow => $session{form}{newWindow},
url => $session{form}{url},
name => $session{form}{name},
sequenceNumber=>$session{form}{sequenceNumber}
});
if ($session{form}{proceed} eq "addLink") {
$session{form}{lid} = "new";
return $_[0]->www_editLink();
} else {
return "";
}
}
#-------------------------------------------------------------------
sub www_moveLinkDown {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->moveCollateralDown("LinkList_link","LinkList_linkId",$session{form}{lid});
return "";
}
#-------------------------------------------------------------------
sub www_moveLinkUp {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId")));
$_[0]->moveCollateralUp("LinkList_link","LinkList_linkId",$session{form}{lid});
return "";
}
#-------------------------------------------------------------------
sub www_view {
my (%var, @linkloop, $controls, $link, $sth);
$var{"addlink.url"} = WebGUI::URL::page('func=editLink&lid=new&wid='.$_[0]->get("wobjectId"));
$var{"addlink.label"} = WebGUI::International::get(13,$_[0]->get("namespace"));
$var{canEdit} = WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId"));
$sth = WebGUI::SQL->read("select * from LinkList_link where wobjectId=".$_[0]->get("wobjectId")."
order by sequenceNumber");
while ($link = $sth->hashRef) {
$controls = deleteIcon('func=deleteLink&wid='.$_[0]->get("wobjectId").'&lid='.$link->{LinkList_linkId})
.editIcon('func=editLink&wid='.$_[0]->get("wobjectId").'&lid='.$link->{LinkList_linkId})
.moveUpIcon('func=moveLinkUp&wid='.$_[0]->get("wobjectId").'&lid='.$link->{LinkList_linkId})
.moveDownIcon('func=moveLinkDown&wid='.$_[0]->get("wobjectId").'&lid='.$link->{LinkList_linkId});
push(@linkloop, {
"link.url"=>$link->{url},
"link.controls"=>$controls,
"link.newWindow"=>$link->{newWindow},
"link.name"=>$link->{name},
"link.description"=>$link->{description}
});
}
$sth->finish;
$var{link_loop} = \@linkloop;
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
}
1;