fixed: Thingy: delete a thing dysfunctions linked things

This commit is contained in:
Yung Han Khoe 2008-04-09 15:42:24 +00:00
parent 17efa03530
commit 3e82c7368d
3 changed files with 33 additions and 14 deletions

View file

@ -11,6 +11,7 @@
- fixed: Thingy: field sequence not imported correctly for existing Thingies - fixed: Thingy: field sequence not imported correctly for existing Thingies
- fixed: anonymous registration leaves user at blank page - fixed: anonymous registration leaves user at blank page
- fixed: Thingy: field type 'other thing' does not stay selected - fixed: Thingy: field type 'other thing' does not stay selected
- fixed: Thingy: delete a thing dysfunctions linked things
7.5.9 7.5.9
- fixed: Collaboration System attachments follow site's max size instead of CS's - fixed: Collaboration System attachments follow site's max size instead of CS's

View file

@ -579,10 +579,14 @@ sub getFieldValue {
elsif ($field->{fieldType} =~ m/^otherThing/x) { elsif ($field->{fieldType} =~ m/^otherThing/x) {
my $otherThingId = $field->{fieldType}; my $otherThingId = $field->{fieldType};
$otherThingId =~ s/^otherThing_//x; $otherThingId =~ s/^otherThing_//x;
($processedValue) = $self->session->db->quickArray('select ' my $tableName = 'Thingy_'.$otherThingId;
.$dbh->quote_identifier('field_'.$field->{fieldInOtherThingId}) my ($otherThingTableExists) = $self->session->db->quickArray('show tables like ?',[$tableName]);
.' from '.$dbh->quote_identifier('Thingy_'.$otherThingId) if ($otherThingTableExists){
.' where thingDataId = ?',[$value]); ($processedValue) = $self->session->db->quickArray('select '
.$dbh->quote_identifier('field_'.$field->{fieldInOtherThingId})
.' from '.$dbh->quote_identifier($tableName)
.' where thingDataId = ?',[$value]);
}
} }
elsif ($field->{fieldType} eq "file") { elsif ($field->{fieldType} eq "file") {
$processedValue = WebGUI::Form::File->new($self->session,{value=>$value})->displayValue(); $processedValue = WebGUI::Form::File->new($self->session,{value=>$value})->displayValue();
@ -609,7 +613,9 @@ sub getFormElement {
my $self = shift; my $self = shift;
my $data = shift; my $data = shift;
my %param; my %param;
my $dbh = $self->session->db->dbh; my $db = $self->session->db;
my $dbh = $db->dbh;
my $i18n = WebGUI::International->new($self->session,"Asset_Thingy");
$param{name} = "field_".$data->{fieldId}; $param{name} = "field_".$data->{fieldId};
my $name = $param{name}; my $name = $param{name};
@ -662,16 +668,23 @@ sub getFormElement {
my $otherThingId = $data->{fieldType}; my $otherThingId = $data->{fieldType};
$otherThingId =~ s/^otherThing_(.*)/$1/x; $otherThingId =~ s/^otherThing_(.*)/$1/x;
$param{fieldType} = "SelectList"; $param{fieldType} = "SelectList";
my $options = ();
my $tableName = 'Thingy_'.$otherThingId;
my ($otherThingTableExists) = $db->quickArray('show tables like ?',[$tableName]);
if ($otherThingTableExists){
$options = $db->buildHashRef('select thingDataId, '
.$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId})
.' from '.$dbh->quote_identifier($tableName));
my $options = $self->session->db->buildHashRef('select thingDataId, ' my $value = $data->{value} || $data->{defaultValue};
.$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId}) ($param{value}) = $db->quickArray('select '
.' from '.$dbh->quote_identifier('Thingy_'.$otherThingId)); .$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId})
.' from '.$dbh->quote_identifier($tableName)
my $value = $data->{value} || $data->{defaultValue}; .' where thingDataId = ?',[$value]);
($param{value}) = $self->session->db->quickArray('select ' }
.$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId}) else{
.' from '.$dbh->quote_identifier('Thingy_'.$otherThingId) return $i18n->get('other thing missing message');
.' where thingDataId = ?',[$value]); }
$param{size} = 1; $param{size} = 1;
$param{multiple} = 0; $param{multiple} = 0;
$param{options} = $options; $param{options} = $options;

View file

@ -896,6 +896,11 @@ search has been done.|,
message => q|Every asset provides a set of variables to most of its templates based on the internal asset properties. Some of these variables may be useful, others may not.|, message => q|Every asset provides a set of variables to most of its templates based on the internal asset properties. Some of these variables may be useful, others may not.|,
lastUpdated => 1164910794, lastUpdated => 1164910794,
}, },
'other thing missing message' => {
message => q|The Thing to which this field refers does not exist or has no table.|,
lastUpdated => 1104630516,
},
}; };
1; 1;