fix - i18n reserved section name in Surveys

fix - typo in Asset_ProjectManager i18n
This commit is contained in:
Roy Johnson 2006-06-05 23:26:17 +00:00
parent e783ce7660
commit 74d9fb12ea
4 changed files with 39 additions and 12 deletions

View file

@ -7,6 +7,8 @@
- fix: Survey Asset Copy Problems
- fix: EMS Add Subevent
- fix: HTTPproxy
- fix: i18n reserved section name in Surveys
- fix: typo in Asset_ProjectManager i18n
6.99.3
- Someone removed the status from the submission templates. That has been

View file

@ -22,8 +22,28 @@ my $session = start(); # this line required
# upgrade functions go here
fixSurvey($session);
finish($session); # this line required
#-------------------------------------------------
sub fixSurvey{
my $session = shift;
print "\tFixing Surveys.\n" unless ($quiet);
# Add a defaultSectionId column to Survey table
$session->db->write("alter table Survey add column (defaultSectionId varchar(22) binary not null)");
# Set defaultSectionId for existing Surveys by finding the sectionId for the section called 'none' and update the asset
my @surveyAssets = $session->db->buildArray("select assetId from asset where className='WebGUI::Asset::Wobject::Survey'");
foreach my $assetId (@surveyAssets) {
my $survey = WebGUI::Asset->new($session, $assetId, 'WebGUI::Asset::Wobject::Survey');
my $i18n = WebGUI::International->new($session, 'Asset_Survey');
my $noneLabel = $i18n->get(107);
my ($defaultSectionId) = $session->db->quickArray("select Survey_sectionId from Survey_section where assetId=? and sectionName=?", [$assetId,$noneLabel]);
$survey->update({defaultSectionId => $defaultSectionId});
}
}
##-------------------------------------------------
#sub exampleFunction {

View file

@ -39,11 +39,13 @@ sub addAnswer {
sub addSection {
my $self = shift;
my $sectionName = shift;
$self->setCollateral("Survey_section","Survey_sectionId",{
my $sectionId = $self->setCollateral("Survey_section","Survey_sectionId",{
Survey_id=>$self->get("Survey_id"),
Survey_sectionId=>"new",
sectionName=>$sectionName
},1,0,"Survey_id");
return $sectionId;
}
#-------------------------------------------------------------------
@ -122,6 +124,10 @@ sub definition {
fieldType => 'template',
defaultValue => 'PBtmpl0000000000000064'
},
defaultSectionId => {
fieldType => 'text',
defaultValue => 'undef'
},
}
});
return $class->SUPER::definition($session, $definition);
@ -580,9 +586,11 @@ sub prepareView {
sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
my $i18n = WebGUI::International->new($self->session);
my $i18n = WebGUI::International->new($self->session,"Asset_Survey");
if ($self->session->form->process("assetId") eq "new") {
$self->addSection($i18n->get(107));
my $defaultSectionId = $self->addSection($i18n->get(107));
$self->update({'defaultSectionId' => $defaultSectionId});
$self->session->errorHandler->warn($defaultSectionId);
}
}
@ -740,15 +748,13 @@ sub www_deleteSectionConfirm {
my $self = shift;
return $self->session->privilege->insufficient() unless ($self->canEdit);
my $i18n = WebGUI::International->new($self->session,'Asset_Survey');
my $none = $i18n->get(107);
my ($sectionName) = $self->session->db->quickArray("select sectionName from Survey_section where Survey_sectionId="
.$self->session->db->quote($self->session->form->process("sid")));
if ($sectionName =~ /$none/) {
my $section_id = $self->session->form->get("sid");
if ($section_id eq $self->get("defaultSectionId")) {
return $self->session->privilege->vitalComponent();
}
$self->session->db->write("delete from Survey_section where Survey_sectionId=".$self->session->db->quote($self->session->form->process("sid")));
$self->deleteCollateral("Survey_section","Survey_sectionId",$self->session->form->process("sid"));
$self->session->db->write("delete from Survey_section where Survey_sectionId=?",[$section_id]);
$self->deleteCollateral("Survey_section","Survey_sectionId",$section_id);
$self->reorderCollateral("Survey_section","Survey_sectionId","Survey_id");
return "";
}
@ -1077,11 +1083,10 @@ sub www_editSection {
my $self = shift;
my ($f, $section, $sectionName);
my $i18n = WebGUI::International->new($self->session, 'Asset_Survey');
my $none = $i18n->get(107);
return $self->session->privilege->insufficient() unless ($self->canEdit);
$section = $self->getCollateral("Survey_section","Survey_sectionId",$self->session->form->process("sid"));
if ($section->{sectionName} =~ /$none/) {
if ($section->{Survey_sectionId} eq $self->get("defaultSectionId") && $section->{Survey_sectionId} ne "") {
return $self->session->privilege->vitalComponent;
}

View file

@ -208,7 +208,7 @@ our $I18N = {
'hours label abbrev' => {
message => q|hrs|,
lastUpdated => 0
lastUpdated => 0,
context => q|Abbreviation for hours|,
},