';
$f = WebGUI::HTMLForm->new;
$f->hidden("wid",$_[0]->get("wobjectId"));
$session{form}{fid} = "new" if ($session{form}{fid} eq "");
$f->hidden("fid",$session{form}{fid});
$f->hidden("func","editFieldSave");
$f->text("name",WebGUI::International::get(21,$_[0]->get("namespace")),$field{name});
$f->text(
-name=>"subtext",
-value=>$field{subtext},
-label=>"Subtext",
-subtext=>"Optional extra text"
);
my $status = [ $field{status} ||= 3 ]; # make it modifiable by default
$f->select("status",\%fieldStatus,WebGUI::International::get(22,$_[0]->get("namespace")),$status);
my $type = [ $field{type} ||= "text" ];
$f->select("type",\%fieldTypes,WebGUI::International::get(23,$_[0]->get("namespace")),$type);
$f->select("validation",\%validation,"Input validation", [$field{validation} || "none"]);
$f->integer("width",WebGUI::International::get(8, $_[0]->get("namespace")),$field{width} || $_[0]->get("width") || 45);
$f->integer(
-name=>"rows",
-value=>$field{rows} || "",
-label=>WebGUI::International::get(27, $_[0]->get("namespace")),
-subtext=>WebGUI::International::get(28, $_[0]->get("namespace")),
);
$f->textarea("possibleValues",WebGUI::International::get(24,$_[0]->get("namespace")),$field{possibleValues});
$f->textarea("defaultValue",WebGUI::International::get(25,$_[0]->get("namespace")),$field{defaultValue});
$f->yesNo("proceed",WebGUI::International::get(15,$_[0]->get("namespace")));
$f->submit;
$output .= $f->print;
return $output;
}
#-------------------------------------------------------------------
sub www_editFieldSave {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
my ($seq);
if ($session{form}{fid} eq "new") {
($seq) = WebGUI::SQL->quickArray("select max(sequenceNumber) from MailForm_field where wobjectId=".$_[0]->get("wobjectId"));
$session{form}{fid} = getNextId("MailForm_fieldId");
WebGUI::SQL->write("insert into MailForm_field (wobjectId,MailForm_fieldId,sequenceNumber, width) values
(".$_[0]->get("wobjectId").",$session{form}{fid},".($seq+1).", $session{form}{width} )");
}
WebGUI::SQL->write("update MailForm_field set name=".quote($session{form}{name}).
", status=".quote($session{form}{status}).
", type=".quote($session{form}{type}).
", possibleValues=".quote($session{form}{possibleValues}).
", defaultValue=".quote($session{form}{defaultValue}).
", width=".quote($session{form}{width}).
", rows=".quote($session{form}{rows}).
", validation=".quote($session{form}{validation}).
", subtext=".quote($session{form}{subtext}).
" where MailForm_fieldId=$session{form}{fid}");
if ($session{form}{proceed}) {
$session{form}{fid} = "new";
return $_[0]->www_editField();
} else {
return "";
}
}
#-------------------------------------------------------------------
sub www_moveFieldDown {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
$_[0]->moveCollateralDown("MailForm_field","MailForm_fieldId",$session{form}{fid});
return "";
}
#-------------------------------------------------------------------
sub www_moveFieldUp {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
$_[0]->moveCollateralUp("MailForm_field","MailForm_fieldId",$session{form}{fid});
return "";
}
#-------------------------------------------------------------------
sub www_view {
my ($output, $sth, $f, $row, %data);
tie %data, 'Tie::CPHash';
$output = $_[0]->displayTitle;
$output .= $_[0]->description.'
';
# get all international text for each field caption
my %text = (
from => WebGUI::International::get(10, $_[0]->get("namespace")),
to => WebGUI::International::get(11, $_[0]->get("namespace")),
cc => WebGUI::International::get(12, $_[0]->get("namespace")),
bcc => WebGUI::International::get(13, $_[0]->get("namespace")),
subject => WebGUI::International::get(14, $_[0]->get("namespace")),
);
if ($session{var}{adminOn}) {
$output .= ''
.WebGUI::International::get(9,$_[0]->get("namespace")).'';
}
$f = WebGUI::HTMLForm->new();
$f->hidden("wid",$_[0]->get("wobjectId"));
$f->hidden('func','send');
foreach my $field (qw(from to cc bcc subject)) {
if ($_[0]->get("${field}Status") == 1) {
# Hidden field, don't show on form for security reasons
} else {
my $row = '
\u$field:
".$_[0]->get("${field}Field");
} else {
# Modifiable Field
if ($field eq 'content') {
my $taWidth = $_[0]->get("width") - 9;
$row .= "top\">".$text{$field}.":
";
$f->raw($row);
}
}
$sth = WebGUI::SQL->read("select * from MailForm_field where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
while (%data = $sth->hash) {
if ($data{status} == 1) {
# hidden field, don't show on form for security reasons
$row = "";
# but show for admins
if ($session{var}{adminOn}) {
$row = "
';
return $row;
}
#-------------------------------------------------------------------
sub _fieldAdminIcons {
my $fid = $_[1];
return ' '.deleteIcon('func=deleteField&wid='.$_[0]->get("wobjectId").'&fid='.$fid)
.editIcon('func=editField&wid='.$_[0]->get("wobjectId").'&fid='.$fid)
.moveUpIcon('func=moveFieldUp&wid='.$_[0]->get("wobjectId").'&fid='.$fid)
.moveDownIcon('func=moveFieldDown&wid='.$_[0]->get("wobjectId").'&fid='.$fid);
}
# Other methods
#-------------------------------------------------------------------
# textSelectRow basically combines HTMLForm::text with HTMLForm::select
# to put a text box and select box on the same table row
sub _textSelectRow {
my ($self, $textName, $textLabel, $textValue, $textMaxLength, $selectName, $selectOptions, $selectValue) = @_;
my $output;
$textValue = WebGUI::Form::_fixQuotes($textValue);
my $textSize = $session{setting}{textBoxSize};
$output = '';
$output .= ' ';
my $selectSize = 1;
$output .= '