Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8f64093b

Von Moritz Bunkus vor etwa 15 Jahren hinzugefügt

  • ID 8f64093b4d58bd4bd72cd7465b7e402ad949eaf1
  • Vorgänger 03ca3d74
  • Nachfolger 11654460

Kosmetik.

Unterschiede anzeigen:

sql/Pg-upgrade2/cp_greeting_migration.pl
8 8

  
9 9
sub mydberror {
10 10
  my ($msg) = @_;
11
  die($dbup_locale->text("Database update error:") .
12
      "<br>$msg<br>" . $DBI::errstr);
11
  die($dbup_locale->text("Database update error:") . "<br>$msg<br>" . $DBI::errstr);
13 12
}
14 13

  
15 14
sub do_query {
......
41 40
    if ($main::form->{"gender_$i"} eq "f" ) {
42 41
			$mchecked = "";
43 42
			$fchecked = "checked";
44
	} else {
43
    } else {
45 44
			$mchecked = "checked";
46 45
			$fchecked = "";
47
	};
46
    };
48 47

  
49
   $gender_table .= "<tr><input type=hidden name=\"cp_id_$i\" value=\"$row->{cp_id}\"> <td>$row->{cp_givenname}</td> <td>$row->{cp_name}</td> <td>$row->{cp_title} </td> <td>$row->{cp_greeting} </td><td> <input type=\"radio\" name=\"gender_$i\" value=\"m\" $mchecked> <input type=\"radio\" name=\"gender_$i\" value=\"f\" $fchecked></td></tr>\n";
50
   $i++;
51
  };
48
    $gender_table .= "<tr><input type=hidden name=\"cp_id_$i\" value=\"$row->{cp_id}\"> <td>$row->{cp_givenname}</td> <td>$row->{cp_name}</td> <td>$row->{cp_title} </td> <td>$row->{cp_greeting} </td><td> <input type=\"radio\" name=\"gender_$i\" value=\"m\" $mchecked> <input type=\"radio\" name=\"gender_$i\" value=\"f\" $fchecked></td></tr>\n";
49
    $i++;
50
  }
52 51

  
53 52
  $gender_table .= "<input type=hidden name=\"number_of_gender_entries\" value=\"$i\">";
54 53
  $gender_table .= "</table>";
......
67 66
  my $j = 1;
68 67
  while (my $row = $sth3->fetchrow_hashref()) {
69 68
# Vorschlagsfeld fuer neuen Titel mit Werten von cp_greeting und cp_title vorbelegen
70
		  my $value = "$row->{cp_greeting}";
71
		  $value .= " " if $row->{cp_greeting};
72
		  $value .= "$row->{cp_title}";
69
    my $value = "$row->{cp_greeting}";
70
    $value .= " " if $row->{cp_greeting};
71
    $value .= "$row->{cp_title}";
73 72

  
74
		  $title_table .= "<tr> <td><input type=hidden name=\"cp_id_title_$j\" value=$row->{cp_id}> $row->{cp_givenname}</td> <td>$row->{cp_name}</td><td>$row->{cp_title}</td> <td>$row->{cp_greeting}</td><td><input type=\"text\" id=\"cp_title_$j\" name=\"cp_name_$j\" value=\"$value\"></td> </tr>\n";
75
		  $j++;
76
  };
73
    $title_table .= "<tr> <td><input type=hidden name=\"cp_id_title_$j\" value=$row->{cp_id}> $row->{cp_givenname}</td> <td>$row->{cp_name}</td><td>$row->{cp_title}</td> <td>$row->{cp_greeting}</td><td><input type=\"text\" id=\"cp_title_$j\" name=\"cp_name_$j\" value=\"$value\"></td> </tr>\n";
74
    $j++;
75
  }
77 76

  
78 77
  $title_table .= "<input type=hidden name=\"number_of_title_entries\" value=\"$j\">";
79 78
  $title_table .= "</table>";
80 79
  $main::form->{title_table} = $title_table;
81

  
82
};
83

  
84

  
80
}
85 81

  
86 82
sub print_question {
87 83
  query_result();
......
113 109
  } else {
114 110
    # case 2: submit button was pressed, hidden field do_migrate was set
115 111
    migrate_data();
116
  };
112
  }
117 113

  
118
return 1;
114
  return 1;
119 115

  
120 116
}
121 117

  
......
133 129

  
134 130
  for (my $i = 1; $i <= $main::form->{number_of_gender_entries}; $i++ ) {
135 131
    next unless $main::form->{"cp_id_$i"};
136
	if ( $main::form->{"gender_$i"} eq "f" ) {
137
	  $sqlcode .= "UPDATE contacts SET cp_gender = \'f\' WHERE cp_id = $main::form->{\"cp_id_$i\"};\n";
138
    };
139
  };
132
    if ( $main::form->{"gender_$i"} eq "f" ) {
133
      $sqlcode .= "UPDATE contacts SET cp_gender = \'f\' WHERE cp_id = $main::form->{\"cp_id_$i\"};\n";
134
    }
135
  }
140 136

  
141 137
  for (my $i = 1; $i <= $main::form->{number_of_title_entries}; $i++ ) {
142 138
    next unless $main::form->{"cp_id_title_$i"} and $main::form->{"cp_id_$i"};
143
	$sqlcode .= "UPDATE contacts SET cp_title = \'$main::form->{\"cp_name_$i\"}\' WHERE cp_id = $main::form->{\"cp_id_$i\"};\n";
144
  };
139
    $sqlcode .= "UPDATE contacts SET cp_title = \'$main::form->{\"cp_name_$i\"}\' WHERE cp_id = $main::form->{\"cp_id_$i\"};\n";
140
  }
145 141
  $sqlcode .= "ALTER TABLE contacts DROP COLUMN cp_greeting;";
146 142

  
147 143
  # insert chosen default values
......
150 146

  
151 147
  my $query  = $sqlcode;
152 148
  do_query($query);
153
};
154

  
155

  
149
}
156 150

  
157 151
sub set_default_greetings {
158 152
  # add html input boxes to template so user can specify default greetings
159 153

  
160
   my $default_male = "Herr";
161
   my $default_female = "Frau";
162

  
163
   my $default_greeting_text_male = "<input type=\"text\" id=\"default_male\" name=\"default_male\" value=\"$default_male\"><br>";
164
   my $default_greeting_text_female = "<input type=\"text\" id=\"default_female\" name=\"default_female\" value=\"$default_female\"><br>";
165
   $main::form->{default_greeting_text_male} = $default_greeting_text_male;
154
   my $default_male                            = "Herr";
155
   my $default_female                          = "Frau";
156
   my $default_greeting_text_male              = "<input type=\"text\" id=\"default_male\" name=\"default_male\" value=\"$default_male\"><br>";
157
   my $default_greeting_text_female            = "<input type=\"text\" id=\"default_female\" name=\"default_female\" value=\"$default_female\"><br>";
158
   $main::form->{default_greeting_text_male}   = $default_greeting_text_male;
166 159
   $main::form->{default_greeting_text_female} = $default_greeting_text_female;
167
};
168

  
160
}
169 161

  
170 162
return do_update();
171 163

  

Auch abrufbar als: Unified diff