WebGUI 2.0.0 release
This commit is contained in:
parent
6cf30b32bd
commit
08a5f757da
10 changed files with 101 additions and 32 deletions
|
|
@ -195,6 +195,7 @@ CREATE TABLE event (
|
|||
description text,
|
||||
startDate int(11) default NULL,
|
||||
endDate int(11) default NULL,
|
||||
recurringEventId int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (eventId)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
|
@ -370,6 +371,7 @@ INSERT INTO incrementer VALUES ('eventId',1);
|
|||
INSERT INTO incrementer VALUES ('linkId',1);
|
||||
INSERT INTO incrementer VALUES ('questionId',1);
|
||||
INSERT INTO incrementer VALUES ('submissionId',1);
|
||||
INSERT INTO incrementer VALUES ('recurringEventId',1);
|
||||
|
||||
#
|
||||
# Table structure for table 'link'
|
||||
|
|
@ -518,7 +520,7 @@ INSERT INTO settings VALUES ('maxAttachmentSize','300');
|
|||
INSERT INTO settings VALUES ('lib','/extras');
|
||||
INSERT INTO settings VALUES ('sessionTimeout','28000');
|
||||
INSERT INTO settings VALUES ('attachmentDirectoryLocal','/data/WebGUI/uploads');
|
||||
INSERT INTO settings VALUES ('smtpServer','smtp.mycompany.com');
|
||||
INSERT INTO settings VALUES ('smtpServer','localhost');
|
||||
INSERT INTO settings VALUES ('companyEmail','info@mycompany.com');
|
||||
INSERT INTO settings VALUES ('ldapURL','ldap://ldap.mycompany.com:389/o=MyCompany');
|
||||
INSERT INTO settings VALUES ('companyName','My Company');
|
||||
|
|
|
|||
2
docs/upgrade_1.3.1-2.0.0.sql
Normal file
2
docs/upgrade_1.3.1-2.0.0.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
alter table event add column recurringEventId int not null;
|
||||
INSERT INTO incrementer VALUES ('recurringEventId',1);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
package WebGUI;
|
||||
our $VERSION = "1.3.1";
|
||||
our $VERSION = "2.0.0";
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001 Plain Black Software.
|
||||
|
|
|
|||
|
|
@ -10,28 +10,35 @@ package WebGUI::Mail;
|
|||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use Net::SMTP;
|
||||
use strict;
|
||||
use WebGUI::ErrorHandler;
|
||||
use WebGUI::Session;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#eg: send("jt@jt.com","hi, how are you","this is my message","bob@bob.com");
|
||||
#eg: send(to,subject,message,cc);
|
||||
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
|
||||
if (defined $smtp) {
|
||||
$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 ($_[3]);
|
||||
$smtp->datasend("Subject: ".$_[1]."\n");
|
||||
$smtp->datasend("\n");
|
||||
# Send the body.
|
||||
$smtp->datasend($_[2]);
|
||||
$smtp->datasend("\n\n $session{setting}{companyName}\n $session{setting}{companyEmail}\n $session{setting}{companyURL}\n");
|
||||
$smtp->dataend(); # Finish sending the mail
|
||||
$smtp->quit; # Close the SMTP connection
|
||||
} else {
|
||||
WebGUI::ErrorHandler::warn("Couldn't connect to mail server: ".$session{setting}{smtpServer});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ use Exporter;
|
|||
use Net::LDAP;
|
||||
use strict;
|
||||
use URI;
|
||||
use WebGUI::ErrorHandler;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Mail;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
|
@ -84,7 +86,12 @@ sub www_createAccount {
|
|||
$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>';
|
||||
$output .= '<div class="accountOptions"><ul>';
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=displayLogin">I already have an account.</a>';
|
||||
if ($session{setting}{authMethod} eq "WebGUI") {
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=recoverPassword">I forgot my password.</a>';
|
||||
}
|
||||
$output .= '</ul></div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -167,7 +174,9 @@ sub www_displayLogin {
|
|||
if ($session{setting}{anonymousRegistration} eq "yes") {
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=createAccount">Create a new account.</a>';
|
||||
}
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=recoverPassword">I forgot my password.</a>';
|
||||
if ($session{setting}{authMethod} eq "WebGUI") {
|
||||
$output .= '<li><a href="'.$session{page}{url}.'?op=recoverPassword">I forgot my password.</a>';
|
||||
}
|
||||
$output .= '</ul></div>';
|
||||
}
|
||||
return $output;
|
||||
|
|
@ -190,8 +199,10 @@ sub www_login {
|
|||
$ldap->unbind;
|
||||
if ($auth->code == 48 || $auth->code == 49) {
|
||||
$error = "The account information you supplied is invalid. Either the account does not exist or the username/password combination was incorrect.";
|
||||
WebGUI::ErrorHandler::warn("Invalid login for user account: ".$session{form}{username});
|
||||
} elsif ($auth->code > 0) {
|
||||
$error .= 'LDAP error "'.$ldapStatusCode{$auth->code}.'" occured. Please contact your system administrator for assistance. ';
|
||||
WebGUI::ErrorHandler::warn("LDAP error: ".$ldapStatusCode{$auth->code});
|
||||
} else {
|
||||
$success = 1;
|
||||
}
|
||||
|
|
@ -200,13 +211,13 @@ sub www_login {
|
|||
$success = 1;
|
||||
} else {
|
||||
$error = "The account information you supplied is invalid. Either the account does not exist or the username/password combination was incorrect.";
|
||||
WebGUI::ErrorHandler::warn("Invalid login for user account: ".$session{form}{username});
|
||||
}
|
||||
}
|
||||
if ($success) {
|
||||
_login($uid,$pass);
|
||||
return "";
|
||||
} else {
|
||||
WebGUI::ErrorHandler::warn($error);
|
||||
return "<h1>Error</h1>".$error.www_displayLogin();
|
||||
}
|
||||
}
|
||||
|
|
@ -252,7 +263,7 @@ sub www_recoverPasswordFinish {
|
|||
$encryptedPassword = Digest::MD5::md5_base64($password);
|
||||
WebGUI::SQL->write("update users 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';
|
||||
$message = "Someone (probably you) requested your account information be sent. Your password has been reset. The following represents your new account information:\nUser: ".$username."\nPass: ".$password."\n";
|
||||
WebGUI::Mail::send($session{form}{email},"Account Information",$message);
|
||||
}
|
||||
$sth->finish();
|
||||
|
|
@ -292,8 +303,10 @@ sub www_saveAccount {
|
|||
$auth = $ldap->bind(dn=>$connectDN, password=>$session{form}{ldapPassword});
|
||||
if ($auth->code == 48 || $auth->code == 49) {
|
||||
$error .= "Either your ".$session{setting}{ldapIdName}." or ".$session{setting}{ldapPasswordName}." were invalid. ";
|
||||
WebGUI::ErrorHandler::warn("Invalid LDAP information for registration of LDAP ID: ".$session{form}{ldapId});
|
||||
} elsif ($auth->code > 0) {
|
||||
$error .= 'LDAP error "'.$ldapStatusCode{$auth->code}.'" occured. Please contact your system administrator for assistance. ';
|
||||
WebGUI::ErrorHandler::warn("LDAP error: ".$ldapStatusCode{$auth->code});
|
||||
}
|
||||
$ldap->unbind;
|
||||
}
|
||||
|
|
@ -306,7 +319,6 @@ sub www_saveAccount {
|
|||
$output .= 'Account created successfully!<p>';
|
||||
$output .= www_displayAccount();
|
||||
} else {
|
||||
WebGUI::ErrorHandler::warn($error);
|
||||
$output = "<h1>Error</h1>".$error.www_createAccount();
|
||||
}
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use WebGUI::Session;
|
|||
use WebGUI::SQL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&getNextId &saveAttachment &round &urlizeTitle "e);
|
||||
our @EXPORT = qw(&randint &getNextId &saveAttachment &round &urlizeTitle "e);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getNextId {
|
||||
|
|
@ -35,6 +35,15 @@ sub quote {
|
|||
return $session{dbh}->quote($value);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub randint {
|
||||
my ($low, $high) = @_;
|
||||
$low = 0 unless defined $low;
|
||||
$high = 1 unless defined $high;
|
||||
($low, $high) = ($high,$low) if $low > $high;
|
||||
return $low + int( rand( $high - $low + 1 ) );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub round {
|
||||
return sprintf("%.0f", $_[0]);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ sub www_addSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addEvent {
|
||||
my ($output, $today);
|
||||
my ($output, $today, %recursEvery);
|
||||
tie %recursEvery, 'Tie::IxHash';
|
||||
%recursEvery = ('never'=>'Happens Only Once','day'=>'Day','week'=>'Week');
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
($today) = epochToSet(time());
|
||||
$output = '<h1>Add Event</h1><form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
|
||||
|
|
@ -76,6 +78,7 @@ sub www_addEvent {
|
|||
$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 class="formDescription">Recurs every</td><td>'.WebGUI::Form::selectList("recursEvery",\%recursEvery).' until '.WebGUI::Form::text("until",20,30,$today,1).'</td></tr>';
|
||||
$output .= '<tr><td></td><td>'.WebGUI::Form::submit("save").'</td></tr>';
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
|
|
@ -87,10 +90,36 @@ sub www_addEvent {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_addEventSave {
|
||||
my ($eventId);
|
||||
my ($i, $recurringEventId, @startDate, @endDate, @eventId, $until);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$eventId = getNextId("eventId");
|
||||
WebGUI::SQL->write("insert into event values ($eventId, $session{form}{wid}, ".quote($session{form}{name}).", ".quote($session{form}{description}).", '".setToEpoch($session{form}{startDate})."', '".setToEpoch($session{form}{endDate})."')",$session{dbh});
|
||||
$startDate[0] = setToEpoch($session{form}{startDate});
|
||||
$endDate[0] = setToEpoch($session{form}{endDate});
|
||||
$until = setToEpoch($session{form}{until});
|
||||
$eventId[0] = getNextId("eventId");
|
||||
if ($session{form}{recursEvery} eq "never") {
|
||||
$recurringEventId = 0;
|
||||
} elsif ($session{form}{recursEvery} eq "day") {
|
||||
$recurringEventId = getNextId("recurringEventId");
|
||||
while ($startDate[$i] < $until) {
|
||||
$i++;
|
||||
$eventId[$i] = getNextId("eventId");
|
||||
$startDate[$i] = $startDate[0] + (86400 * $i);
|
||||
$endDate[$i] = $endDate[0] + (86400 * $i);
|
||||
}
|
||||
} elsif ($session{form}{recursEvery} eq "week") {
|
||||
$recurringEventId = getNextId("recurringEventId");
|
||||
while ($startDate[$i] < $until) {
|
||||
$i++;
|
||||
$eventId[$i] = getNextId("eventId");
|
||||
$startDate[$i] = $startDate[0] + (604800 * $i);
|
||||
$endDate[$i] = $endDate[0] + (604800 * $i);
|
||||
}
|
||||
}
|
||||
$i = 0;
|
||||
while ($eventId[$i] > 0) {
|
||||
WebGUI::SQL->write("insert into event values ($eventId[$i], $session{form}{wid}, ".quote($session{form}{name}).", ".quote($session{form}{description}).", '".$startDate[$i]."', '".$endDate[$i]."', $recurringEventId)",$session{dbh});
|
||||
$i++;
|
||||
}
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -102,7 +131,11 @@ 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>';
|
||||
$output .= 'Are you certain that you want to delete this event';
|
||||
if ($session{form}{rid} > 0) {
|
||||
$output .= ' <b>and</b> all of its recurring events';
|
||||
}
|
||||
$output .= '?<p><div align="center"><a href="'.$session{page}{url}.'?func=deleteEventConfirm&wid='.$session{form}{wid}.'&eid='.$session{form}{eid}.'&rid='.$session{form}{rid}.'">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();
|
||||
|
|
@ -113,7 +146,11 @@ sub www_deleteEvent {
|
|||
sub www_deleteEventConfirm {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
WebGUI::SQL->write("delete from event where eventId=$session{form}{eid}",$session{dbh});
|
||||
if ($session{form}{rid} > 0) {
|
||||
WebGUI::SQL->write("delete from event where recurringEventId=$session{form}{rid}",$session{dbh});
|
||||
} else {
|
||||
WebGUI::SQL->write("delete from event where eventId=$session{form}{eid}",$session{dbh});
|
||||
}
|
||||
return www_edit();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -138,9 +175,9 @@ sub www_edit {
|
|||
$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});
|
||||
$sth = WebGUI::SQL->read("select eventId, name, recurringEventId 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>';
|
||||
$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].'&rid='.$event[2].'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a></td><td>'.$event[1].'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ 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}.'&qid='.$session{form}{qid}.'">Yes, I\'m sure.</a> <a href="'.$session{page}{url}.'?func=edit&wid='.$session{form}{wid}.'">No, I made a mistake.</a></div>';
|
||||
$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}.'&qid='.$session{form}{qid}.'">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();
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ 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>';
|
||||
$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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue