Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 07cd1c32

Von Cem Aydin vor mehr als 2 Jahren hinzugefügt

  • ID 07cd1c32b8e3a12e3afb18d5c51f36262b2e24ca
  • Vorgänger a5b0b43c
  • Nachfolger 16485ecf

Beim Erstellen neuer Benutzer Dialog anzeigen, wenn der Loginname schon einmal
verwendet wurde.

Auswahlmöglichkeit im Dialog ob Belege von gelöschten Benutzern mit demselben
Loginnamen, dem neuen Benutzer zugewiesen werden sollen

Falls nein wird derselbe Benutzername in der employee table eindeutig
umbenannt. Falls ja bleibt das Verhalten gleich wie bis anhin.

Fix zu #501.

Unterschiede anzeigen:

SL/Controller/Admin.pm
137 137
  my $params = delete($::form->{user})          || { };
138 138
  my $props  = delete($params->{config_values}) || { };
139 139
  my $is_new = !$params->{id};
140
  my $check_previously_used = delete($::form->{check_previously_used}) || 0;
141
  my $assign_documents = delete($::form->{assign_documents}) || 0;
140 142

  
141 143
  # Assign empty arrays if the browser doesn't send those controls.
142 144
  $params->{clients} ||= [];
......
149 151
  my @errors = $self->user->validate;
150 152

  
151 153
  if (@errors) {
152
    flash('error', @errors);
153
    $self->edit_user_form(title => $is_new ? t8('Create a new user') : t8('Edit User'));
154
    return;
154
    $self->js->flash('error', $_) foreach @errors;
155
    return $self->js->render();
156
  }
157

  
158
  # check if given login name was previously used and show a dialog if so
159
  if ($is_new && $check_previously_used && $self->check_loginname_previously_used()) {
160
    $self->js->run('show_loginname_previously_used_dialog');
161
    return $self->js->render();
162
  }
163

  
164
  # rename previous usernames in employee table, if not set to assign
165
  if ($is_new && !$assign_documents) {
166
    my $clients = SL::DB::Manager::AuthClient->get_all_sorted;
167
    for my $client (@$clients) {
168
      my $now = DateTime->now_local;
169
      my $timestamp = $now->format_cldr('yyyyMMddHHmmss');
170

  
171
      my $dbh = $client->dbconnect(AutoCommit => 1);
172
      $dbh->do(qq|UPDATE employee SET login = ? WHERE login = ?;|,undef,
173
               $params->{'login'} . $timestamp, $params->{'login'});
174
      $dbh->disconnect;
175
    }
155 176
  }
156 177

  
157 178
  $self->user->save;
......
762 783
  return (%result, error => $::locale->text('The database user \'#1\' does not have superuser privileges.', $result{username}));
763 784
}
764 785

  
786
sub check_loginname_previously_used() {
787
  my ($self) = @_;
788

  
789
  my $clients = SL::DB::Manager::AuthClient->get_all_sorted;
790
  for my $client (@$clients) {
791
    my $dbh = $client->dbconnect();
792
    my ($result) = $dbh->selectrow_array(qq|SELECT login FROM employee WHERE login = ?;|,undef,
793
                                        $self->user->{'login'});
794
    $dbh->disconnect;
795

  
796
    if ($result) {
797
      return 1;
798
    }
799
  }
800
  return 0;
801
}
802

  
765 803
1;
js/locale/de.js
93 93
"June":"Juni",
94 94
"Leading and trailing whitespaces have been removed.":"Leerzeichen wurden vorne und hinten entfernt",
95 95
"Loading...":"Wird geladen...",
96
"Login name was previously used":"Benutzername wurde schon mal verwendet",
96 97
"Map":"Karte",
97 98
"Mar":"März",
98 99
"March":"März",
......
158 159
"The action can only be executed once.":"Die Aktion kann nur einmal ausgeführt werden.",
159 160
"The customer order number is missing. Do you want to continue anyway?":"Die Kundenbestellnummer fehlt. Möchten Sie trotzdem fortfahren?",
160 161
"The description is missing.":"Die Beschreibung fehlt.",
162
"The login name you entered was previously used. Do you want to assign documents from the former user that had the same username to the new user?":"Der eingegebene Benutzername war schon einmal vergeben. Sollen Belege des früheren Benutzers mit dem selben Benutzernamen dem neuen Benutzer zugewiesen werden?",
161 163
"The name is missing.":"Der Name fehlt.",
162 164
"The name must only consist of letters, numbers and underscores and start with a letter.":"Der Name darf nur aus Buchstaben (keine Umlaute), Ziffern und Unterstrichen bestehen und muss mit einem Buchstaben beginnen.",
163 165
"The option field is empty.":"Das Optionsfeld ist leer.",
js/locale/en.js
93 93
"June":"",
94 94
"Leading and trailing whitespaces have been removed.":"",
95 95
"Loading...":"",
96
"Login name was previously used":"",
96 97
"Map":"",
97 98
"Mar":"",
98 99
"March":"",
......
158 159
"The action can only be executed once.":"",
159 160
"The customer order number is missing. Do you want to continue anyway?":"",
160 161
"The description is missing.":"",
162
"The login name you entered was previously used. Do you want to assign documents from the former user that had the same username to the new user?":"",
161 163
"The name is missing.":"",
162 164
"The name must only consist of letters, numbers and underscores and start with a letter.":"",
163 165
"The option field is empty.":"",
locale/de/all
2049 2049
  'Lockfile removed!'           => 'System entsperrt!',
2050 2050
  'Login'                       => 'Anmelden',
2051 2051
  'Login Name'                  => 'Benutzer',
2052
  'Login name was previously used' => 'Benutzername wurde schon mal verwendet',
2052 2053
  'Login of User'               => 'Login',
2053 2054
  'Logout'                      => 'Abmelden',
2054 2055
  'Logout now'                  => 'kivitendo jetzt verlassen',
......
3673 3674
  'The list has been printed.'  => 'Die Liste wurde ausgedruckt.',
3674 3675
  'The login is missing.'       => 'Der Loginname fehlt.',
3675 3676
  'The login is not unique.'    => 'Der Loginname ist nicht eindeutig.',
3677
  'The login name you entered was previously used. Do you want to assign documents from the former user that had the same username to the new user?' => 'Der eingegebene Benutzername war schon einmal vergeben. Sollen Belege des früheren Benutzers mit dem selben Benutzernamen dem neuen Benutzer zugewiesen werden?',
3676 3678
  'The long description is missing.' => 'Der Langtext fehlt.',
3677 3679
  'The master templates where not found.' => 'Der Vorlagensatz wurde nicht gefunden.',
3678 3680
  'The maximum of uploadable filesize in Megabyte' => 'Die maximale Dateigröße in Megabytes, die hochladbar ist',
locale/en/all
2049 2049
  'Lockfile removed!'           => '',
2050 2050
  'Login'                       => '',
2051 2051
  'Login Name'                  => '',
2052
  'Login name was previously used' => '',
2052 2053
  'Login of User'               => '',
2053 2054
  'Logout'                      => '',
2054 2055
  'Logout now'                  => '',
......
3672 3673
  'The list has been printed.'  => '',
3673 3674
  'The login is missing.'       => '',
3674 3675
  'The login is not unique.'    => '',
3676
  'The login name you entered was previously used. Do you want to assign documents from the former user that had the same username to the new user?' => '',
3675 3677
  'The long description is missing.' => '',
3676 3678
  'The master templates where not found.' => '',
3677 3679
  'The maximum of uploadable filesize in Megabyte' => '',
templates/webpages/admin/edit_user.html
8 8
<form method="post" action="controller.pl" id="form">
9 9
 [% L.hidden_tag("user.id", SELF.user.id) %]
10 10
 [% L.hidden_tag("action", "") %]
11
 [% L.hidden_tag("check_previously_used", "0") %]
12
 [% L.hidden_tag("assign_documents", "0") %]
11 13
 [%- SET props=SELF.user.config_values %]
12 14

  
13 15
 <h2>[%- LxERP.t8("Settings") %]</h2>
......
89 91
       [% L.radio_button_tag('user.config_values.mandatory_departments', value='1', id='user.config_values.mandatory_departments_1', label=LxERP.t8('Yes'), checked= props.mandatory_departments) %]
90 92
      </td>
91 93
     </tr>
94

  
92 95
    </table>
93 96
   </td>
94 97
  </tr>
......
149 152
<p>
150 153
 [% L.link(SELF.url_for(action="show"), LxERP.t8("Back")) %]
151 154

  
152
 [% L.button_tag("submit_with_action('save_user')", LxERP.t8("Save")) %]
155
 [% L.button_tag("save_new()", LxERP.t8("Save")) %]
153 156
 [% IF SELF.user.id %]
154 157
  [% L.button_tag("save_as_new()", LxERP.t8("Save as new")) %]
155 158
  [% L.button_tag("submit_delete()", LxERP.t8("Delete"), confirm=LxERP.t8("Are you sure?")) %]
......
175 178
[% END %]
176 179
  }
177 180

  
181
  function save() {
182
    $("#action").val('Admin/save_user');
183
    var data = $('#form').serializeArray();
184
    $.post("controller.pl", data, kivi.eval_json_result);
185
  }
186

  
187
  function save_new() {
188
    $("#check_previously_used").val("1");
189
    save();
190
  }
191

  
178 192
  function save_as_new() {
179 193
    $("#user_id").val("");
180
    submit_with_action("save_user");
194
    $("#check_previously_used").val("1");
195
    save();
196
  }
197

  
198
  function show_loginname_previously_used_dialog() {
199
    var buttons = {};
200
    buttons[kivi.t8('Yes')] = function() {
201
      $("#check_previously_used").val("0");
202
      $("#assign_documents").val("1");
203
      save();
204
    };
205
    buttons[kivi.t8('No')] = function() {
206
      $("#check_previously_used").val("0");
207
      save();
208
    };
209
    buttons[kivi.t8('Cancel')] = function() { $( this ).dialog('close'); };
210

  
211
    kivi.popup_dialog({
212
      id: 'loginname_previously_used_dialog',
213
      html: kivi.t8('The login name you entered was previously used. Do you want to assign documents from the former user that had the same username to the new user?'),
214
      dialog: {
215
        title:  kivi.t8('Login name was previously used'),
216
        width:  400,
217
        height: 250,
218
        buttons: buttons
219
      }
220
    });
181 221
  }
182 222
   -->
183 223
</script>

Auch abrufbar als: Unified diff