';
$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,$namespace),$field{name});
my $status = [ $field{status} ||= 3 ]; # make it modifiable by default
$f->select("status",\%fieldStatus,WebGUI::International::get(22,$namespace),$status);
my $type = [ $field{type} ||= "text" ];
$f->select("type",\%fieldTypes,WebGUI::International::get(23,$namespace),$type);
$f->textarea("possibleValues",WebGUI::International::get(24,$namespace),$field{possibleValues});
$f->text("defaultValue",WebGUI::International::get(25,$namespace),$field{defaultValue});
$f->yesNo("proceed",WebGUI::International::get(15,$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) values
(".$_[0]->get("wobjectId").",$session{form}{fid},".($seq+1).")");
}
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}).
" 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, $namespace),
to => WebGUI::International::get(11, $namespace),
cc => WebGUI::International::get(12, $namespace),
bcc => WebGUI::International::get(13, $namespace),
subject => WebGUI::International::get(14, $namespace),
);
if ($session{var}{adminOn}) {
$output .= ''
.WebGUI::International::get(9,$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) {
# process macros on default values
$data{defaultValue} = $_[0]->processMacros($data{defaultValue});
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 .= '