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: anonymous registration leaves user at blank page
- fixed: Thingy: field type 'other thing' does not stay selected
- fixed: Thingy: delete a thing dysfunctions linked things
7.5.9
- 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) {
my $otherThingId = $field->{fieldType};
$otherThingId =~ s/^otherThing_//x;
($processedValue) = $self->session->db->quickArray('select '
.$dbh->quote_identifier('field_'.$field->{fieldInOtherThingId})
.' from '.$dbh->quote_identifier('Thingy_'.$otherThingId)
.' where thingDataId = ?',[$value]);
my $tableName = 'Thingy_'.$otherThingId;
my ($otherThingTableExists) = $self->session->db->quickArray('show tables like ?',[$tableName]);
if ($otherThingTableExists){
($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") {
$processedValue = WebGUI::Form::File->new($self->session,{value=>$value})->displayValue();
@ -609,7 +613,9 @@ sub getFormElement {
my $self = shift;
my $data = shift;
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};
my $name = $param{name};
@ -662,16 +668,23 @@ sub getFormElement {
my $otherThingId = $data->{fieldType};
$otherThingId =~ s/^otherThing_(.*)/$1/x;
$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, '
.$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId})
.' from '.$dbh->quote_identifier('Thingy_'.$otherThingId));
my $value = $data->{value} || $data->{defaultValue};
($param{value}) = $self->session->db->quickArray('select '
.$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId})
.' from '.$dbh->quote_identifier('Thingy_'.$otherThingId)
.' where thingDataId = ?',[$value]);
my $value = $data->{value} || $data->{defaultValue};
($param{value}) = $db->quickArray('select '
.$dbh->quote_identifier('field_'.$data->{fieldInOtherThingId})
.' from '.$dbh->quote_identifier($tableName)
.' where thingDataId = ?',[$value]);
}
else{
return $i18n->get('other thing missing message');
}
$param{size} = 1;
$param{multiple} = 0;
$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.|,
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;