Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4b7433f4

Von Sven Schöling vor mehr als 14 Jahren hinzugefügt

  • ID 4b7433f44317fcd0f33f157f0effe752a0c5ac6f
  • Vorgänger ee454f5b
  • Nachfolger 5923380f

CVar->get_configs cached jetzt so, wie es io.pl eh schon tut.

Unterschiede anzeigen:

SL/CVar.pm
25 25
    push @values, $params{module};
26 26
  }
27 27

  
28
  my $query    = qq|SELECT * FROM custom_variable_configs $where ORDER BY sortkey|;
28
  my $query    = <<SQL;
29
    SELECT *, date_trunc('seconds', localtimestamp) AS current_timestamp
30
    FROM custom_variable_configs $where ORDER BY sortkey
31
SQL
29 32

  
30
  my $configs  = selectall_hashref_query($form, $dbh, $query, @values);
33
  if (!$::form->{CVAR_CONFIGS}->{$params{module}}) {
34
    my $configs  = selectall_hashref_query($form, $dbh, $query, @values);
31 35

  
32
  foreach my $config (@{ $configs }) {
33
    if ($config->{type} eq 'select') {
34
      $config->{OPTIONS} = [ map { { 'value' => $_ } } split(m/\#\#/, $config->{options}) ];
36
    foreach my $config (@{ $configs }) {
37
      if ($config->{type} eq 'select') {
38
        $config->{OPTIONS} = [ map { { 'value' => $_ } } split(m/\#\#/, $config->{options}) ];
35 39

  
36
    } elsif ($config->{type} eq 'number') {
37
      $config->{precision} = $1 if ($config->{options} =~ m/precision=(\d+)/i);
40
      } elsif ($config->{type} eq 'number') {
41
        $config->{precision} = $1 if ($config->{options} =~ m/precision=(\d+)/i);
38 42

  
39
    }
43
      }
40 44

  
41
    $self->_unpack_flags($config);
45
      $self->_unpack_flags($config);
46
    }
47
    $::form->{CVAR_CONFIGS}->{$params{module}} = $configs;
42 48
  }
43 49

  
44 50
  $main::lxdebug->leave_sub();
45 51

  
46
  return $configs;
52
  return $::form->{CVAR_CONFIGS}->{$params{module}};
47 53
}
48 54

  
49 55
sub get_config {
......
191 197

  
192 198
  my $trans_id = $params{trans_id} ? 'OR (v.trans_id = ?) ' : '';
193 199

  
194
  my $q_cfg    =
195
    qq|SELECT id, name, description, type, default_value, options,
196
         date_trunc('seconds', localtimestamp) AS current_timestamp, current_date AS current_date
197
       FROM custom_variable_configs
198
       WHERE module = ?
199
       ORDER BY sortkey|;
200

  
201 200
  my $q_var    =
202 201
    qq|SELECT text_value, timestamp_value, timestamp_value::date AS date_value, number_value, bool_value
203 202
       FROM custom_variables
......
205 204
  $q_var      .= qq| AND (sub_module = ?)| if $params{sub_module};
206 205
  my $h_var    = prepare_query($form, $dbh, $q_var);
207 206

  
208
  my $custom_variables = selectall_hashref_query($form, $dbh, $q_cfg, $params{module});
207
  my $custom_variables = $self->get_configs(module => $params{module});
209 208

  
210 209
  foreach my $cvar (@{ $custom_variables }) {
211 210
    if ($cvar->{type} eq 'textfield') {

Auch abrufbar als: Unified diff