WebGUI 2.7.0 release

This commit is contained in:
JT Smith 2001-12-31 23:34:00 +00:00
parent c0463670e8
commit 08b81c6064
104 changed files with 7333 additions and 2576 deletions

View file

@ -18,19 +18,29 @@ use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::Shortcut;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub duplicate {
my (%data, $newWidgetId, $pageId);
tie %data, 'Tie::CPHash';
%data = getProperties($namespace,$_[0]);
$pageId = $_[1] || $data{pageId};
$newWidgetId = create($pageId,$namespace,$data{title},$data{displayTitle},$data{description},$data{processMacros},$data{position});
WebGUI::SQL->write("insert into SQLReport values($newWidgetId, ".quote($data{template}).", ".quote($data{dbQuery}).", ".quote($data{DSN}).", ".quote($data{username}).", ".quote($data{identifier}).", '$data{convertCarriageReturns}')");
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from SQLReport where widgetId=$_[0]",$_[1]);
purgeWidget($_[0],$_[1]);
purgeWidget($_[0],$_[1],$namespace);
}
#-------------------------------------------------------------------
sub widgetName {
return WebGUI::International::get(259);
return WebGUI::International::get(1,$namespace);
}
#-------------------------------------------------------------------
@ -38,25 +48,25 @@ sub www_add {
my ($output, %hash);
tie %hash, 'Tie::IxHash';
if (WebGUI::Privilege::canEditPage()) {
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=1&namespace='.$namespace.'"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a>';
$output .= '<h1>'.WebGUI::International::get(260).'</h1>';
$output .= '<form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
$output = helpLink(1,$namespace);
$output .= '<h1>'.WebGUI::International::get(2,$namespace).'</h1>';
$output .= formHeader();
$output .= WebGUI::Form::hidden("widget",$namespace);
$output .= WebGUI::Form::hidden("func","addSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(99).'</td><td>'.WebGUI::Form::text("title",20,128,'SQL Report').'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(174).'</td><td>'.WebGUI::Form::checkbox("displayTitle",1,1).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(175).'</td><td>'.WebGUI::Form::checkbox("processMacros",1,1).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("title",20,128,'SQL Report'));
$output .= tableFormRow(WebGUI::International::get(174),WebGUI::Form::checkbox("displayTitle",1,1));
$output .= tableFormRow(WebGUI::International::get(175),WebGUI::Form::checkbox("processMacros",1,1));
%hash = WebGUI::Widget::getPositions();
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(363).'</td><td>'.WebGUI::Form::selectList("position",\%hash).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(85).'</td><td>'.WebGUI::Form::textArea("description",'','','',1).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(261).'</td><td>'.WebGUI::Form::textArea("template",'','','',1).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(262).'</td><td>'.WebGUI::Form::textArea("dbQuery",'').'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(263).'</td><td>'.WebGUI::Form::text("DSN",20,255,$session{config}{dsn}).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(264).'</td><td>'.WebGUI::Form::text("username",20,255,$session{config}{dbuser}).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(265).'</td><td>'.WebGUI::Form::password("identifier",20,255).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(183).'</td><td>'.WebGUI::Form::checkbox("convertCarriageReturns",1).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(363),WebGUI::Form::selectList("position",\%hash));
$output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",'','','',1));
$output .= tableFormRow(WebGUI::International::get(3,$namespace),WebGUI::Form::textArea("template",'','','',1));
$output .= tableFormRow(WebGUI::International::get(4,$namespace),WebGUI::Form::textArea("dbQuery",''));
$output .= tableFormRow(WebGUI::International::get(5,$namespace),WebGUI::Form::text("DSN",20,255,$session{config}{dsn}));
$output .= tableFormRow(WebGUI::International::get(6,$namespace),WebGUI::Form::text("username",20,255,$session{config}{dbuser}));
$output .= tableFormRow(WebGUI::International::get(7,$namespace),WebGUI::Form::password("identifier",20,255));
$output .= tableFormRow(WebGUI::International::get(183),WebGUI::Form::checkbox("convertCarriageReturns",1));
$output .= formSave();
$output .= '</table></form>';
return $output;
} else {
@ -69,41 +79,51 @@ sub www_add {
sub www_addSave {
my ($widgetId);
if (WebGUI::Privilege::canEditPage()) {
$widgetId = create();
WebGUI::SQL->write("insert into SQLReport values($widgetId, ".quote($session{form}{template}).", ".quote($session{form}{dbQuery}).", ".quote($session{form}{DSN}).", ".quote($session{form}{username}).", ".quote($session{form}{identifier}).", '$session{form}{convertCarriageReturns}')",$session{dbh});
$widgetId = create($session{page}{pageId},$session{form}{widget},$session{form}{title},$session{form}{displayTitle},$session{form}{description},$session{form}{processMacros},$session{form}{position});
WebGUI::SQL->write("insert into SQLReport values($widgetId, ".quote($session{form}{template}).", ".quote($session{form}{dbQuery}).", ".quote($session{form}{DSN}).", ".quote($session{form}{username}).", ".quote($session{form}{identifier}).", '$session{form}{convertCarriageReturns}')");
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_copy {
if (WebGUI::Privilege::canEditPage()) {
duplicate($session{form}{wid});
return "";
} else {
return WebGUI::Privilege::insufficient();
}
}
#-------------------------------------------------------------------
sub www_edit {
my ($output, %data, %hash, @array);
tie %data, 'Tie::CPHash';
tie %hash, 'Tie::IxHash';
if (WebGUI::Privilege::canEditPage()) {
%data = WebGUI::SQL->quickHash("select * from widget,SQLReport where widget.widgetId=$session{form}{wid} and widget.widgetId=SQLReport.widgetId",$session{dbh});
$output = '<a href="'.$session{page}{url}.'?op=viewHelp&hid=1&namespace='.$namespace.'"><img src="'.$session{setting}{lib}.'/help.gif" border="0" align="right"></a>';
$output .= '<h1>'.WebGUI::International::get(266).'</h1>';
$output .= '<form method="post" enctype="multipart/form-data" action="'.$session{page}{url}.'">';
%data = getProperties($namespace,$session{form}{wid});
$output = helpLink(1,$namespace);
$output .= '<h1>'.WebGUI::International::get(8,$namespace).'</h1>';
$output .= formHeader();
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
$output .= WebGUI::Form::hidden("func","editSave");
$output .= '<table>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(99).'</td><td>'.WebGUI::Form::text("title",20,128,$data{title}).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(174).'</td><td>'.WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(175).'</td><td>'.WebGUI::Form::checkbox("processMacros","1",$data{processMacros}).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("title",20,128,$data{title}));
$output .= tableFormRow(WebGUI::International::get(174),WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}));
$output .= tableFormRow(WebGUI::International::get(175),WebGUI::Form::checkbox("processMacros","1",$data{processMacros}));
%hash = WebGUI::Widget::getPositions();
$array[0] = $data{position};
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(363).'</td><td>'.WebGUI::Form::selectList("position",\%hash,\@array).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(85).'</td><td>'.WebGUI::Form::textArea("description",$data{description},50,10,1).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(261).'</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">'.WebGUI::International::get(262).'</td><td>'.WebGUI::Form::text("DSN",20,255,$data{DSN}).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(263).'</td><td>'.WebGUI::Form::text("username",20,255,$data{username}).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(264).'</td><td>'.WebGUI::Form::password("identifier",20,255,$data{identifier}).'</td></tr>';
$output .= '<tr><td class="formDescription">'.WebGUI::International::get(183).'</td><td>'.WebGUI::Form::checkbox("convertCarriageReturns",1,$data{convertCarriageReturns}).'</td></tr>';
$output .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
$output .= tableFormRow(WebGUI::International::get(363),WebGUI::Form::selectList("position",\%hash,\@array));
$output .= tableFormRow(WebGUI::International::get(85),WebGUI::Form::textArea("description",$data{description},50,10,1));
$output .= tableFormRow(WebGUI::International::get(3,$namespace),WebGUI::Form::textArea("template",$data{template},50,10,1));
$output .= tableFormRow(WebGUI::International::get(4,$namespace),WebGUI::Form::textArea("dbQuery",$data{dbQuery},50,10,1));
$output .= tableFormRow(WebGUI::International::get(5,$namespace),WebGUI::Form::text("DSN",20,255,$data{DSN}));
$output .= tableFormRow(WebGUI::International::get(6,$namespace),WebGUI::Form::text("username",20,255,$data{username}));
$output .= tableFormRow(WebGUI::International::get(7,$namespace),WebGUI::Form::password("identifier",20,255,$data{identifier}));
$output .= tableFormRow(WebGUI::International::get(183),WebGUI::Form::checkbox("convertCarriageReturns",1,$data{convertCarriageReturns}));
$output .= formSave();
$output .= '</table></form>';
return $output;
} else {
@ -116,7 +136,7 @@ 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}).", convertCarriageReturns='$session{form}{convertCarriageReturns}', DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier})." where widgetId=$session{form}{wid}",$session{dbh});
WebGUI::SQL->write("update SQLReport set template=".quote($session{form}{template}).", dbQuery=".quote($session{form}{dbQuery}).", convertCarriageReturns='$session{form}{convertCarriageReturns}', DSN=".quote($session{form}{DSN}).", username=".quote($session{form}{username}).", identifier=".quote($session{form}{identifier})." where widgetId=$session{form}{wid}");
return "";
} else {
return WebGUI::Privilege::insufficient();
@ -125,10 +145,9 @@ sub www_editSave {
#-------------------------------------------------------------------
sub www_view {
my ($ouch, %data, $output, $widgetId, $sth, $dbh, @result, @template, $temp);
my ($ouch, %data, $output, $sth, $dbh, @result, @template, $temp);
tie %data, 'Tie::CPHash';
$widgetId = shift;
%data = WebGUI::SQL->quickHash("select * from widget,SQLReport where widget.widgetId=$widgetId and widget.widgetId=SQLReport.widgetId",$session{dbh});
%data = getProperties($namespace,$_[0]);
if (defined %data) {
if ($data{displayTitle} == 1) {
$output = "<h1>".$data{title}."</h1>";
@ -141,15 +160,15 @@ sub www_view {
if ($data{DSN} =~ /\DBI\:\w+\:\w+/) {
$dbh = DBI->connect($data{DSN},$data{username},$data{identifier});
} else {
$output .= WebGUI::International::get(267).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$widgetId] The DSN specified is of an improper format.");
$output .= WebGUI::International::get(9,$namespace).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] The DSN specified is of an improper format.");
}
if (defined $dbh) {
if ($data{dbQuery} =~ /select/i) {
$sth = WebGUI::SQL->unconditionalRead($data{dbQuery},$dbh);
} else {
$output .= WebGUI::International::get(268).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$widgetId] The SQL query is improperly formatted.");
$output .= WebGUI::International::get(10,$namespace).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] The SQL query is improperly formatted.");
}
if ($sth->rows > 0) {
while (@result = $sth->array) {
@ -162,13 +181,13 @@ sub www_view {
}
$sth->finish;
} else {
$output .= WebGUI::International::get(269).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$widgetId] There was a problem with the query.");
$output .= WebGUI::International::get(11,$namespace).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] There was a problem with the query.");
}
$dbh->disconnect();
} else {
$output .= WebGUI::International::get(270).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$widgetId] Could not connect to remote database.");
$output .= WebGUI::International::get(12,$namespace).'<p>';
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] Could not connect to remote database.");
}
$output .= $template[2];
}