Changeset 13510
- Timestamp:
- 11/20/07 13:44:23 (1 year ago)
- Files:
-
- trunk/midcom/midcom.admin.user/config/config.inc (modified) (1 diff)
- trunk/midcom/midcom.admin.user/documentation (added)
- trunk/midcom/midcom.admin.user/documentation/CHANGES (added)
- trunk/midcom/midcom.admin.user/handler/list.php (modified) (2 diffs)
- trunk/midcom/midcom.admin.user/handler/user/edit.php (modified) (5 diffs)
- trunk/midcom/midcom.admin.user/locale/default.en.txt (modified) (14 diffs)
- trunk/midcom/midcom.admin.user/locale/default.fi.txt (modified) (14 diffs)
- trunk/midcom/midcom.admin.user/plugin.php (modified) (3 diffs)
- trunk/midcom/midcom.admin.user/static/usermgmt.css (modified) (1 diff)
- trunk/midcom/midcom.admin.user/style/midcom-admin-user-generate-passwords.php (modified) (3 diffs)
- trunk/midcom/midcom.admin.user/style/midcom-admin-user-password-email.php (added)
- trunk/midcom/midcom.admin.user/style/midcom-admin-user-password-nonajax-header.php (added)
- trunk/midcom/midcom.admin.user/style/midcom-admin-user-passwords-list.php (added)
- trunk/midcom/midcom.admin.user/style/midcom-admin-user-personlist-footer.php (modified) (4 diffs)
- trunk/midcom/midcom.admin.user/style/midcom-admin-user-personlist-header.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.admin.user/config/config.inc
r13076 r13510 22 22 'city', 23 23 ), 24 'message_subject' => 'your password has been changed', 25 'message_body' => "Your password has been changed. Your new password is __PASSWORD__ 26 27 -- 28 __FROM__ - __LONGDATE__ 29 ", 30 'message_sender' => 'www-data@kaktus.cc', trunk/midcom/midcom.admin.user/handler/list.php
r13501 r13510 111 111 $data['search_fields'] = $this->_config->get('search_fields'); 112 112 $data['list_fields'] = $this->_config->get('list_fields'); 113 114 // Set the passwords elsewhere, but check the request first 115 if ( isset($_POST['midcom_admin_user_action']) 116 && $_POST['midcom_admin_user_action'] === 'passwords') 117 { 118 if ( !isset($_POST['midcom_admin_user']) 119 || count($_POST['midcom_admin_user']) === 0) 120 { 121 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), $this->_l10n->get('empty selection')); 122 } 123 else 124 { 125 $get = implode('&midcom_admin_user[]=', $_POST['midcom_admin_user']); 126 127 $_MIDCOM->relocate("__mfa/asgard_midcom.admin.user/password/batch/?midcom_admin_user[]={$get}"); 128 // This will exit 129 } 130 } 113 131 114 132 if ( isset($_POST['midcom_admin_user']) … … 147 165 } 148 166 } 167 break; 149 168 } 150 169 } trunk/midcom/midcom.admin.user/handler/user/edit.php
r13506 r13510 30 30 function _on_initialize() 31 31 { 32 33 32 $this->_l10n = $_MIDCOM->i18n->get_l10n('midcom.admin.user'); 34 33 $this->_request_data['l10n'] = $this->_l10n; … … 45 44 46 45 midgard_admin_asgard_plugin::prepare_plugin($this->_l10n->get('midcom.admin.user'),$this->_request_data); 47 48 46 } 49 47 … … 77 75 function _prepare_toolbar(&$data,$handler_id) 78 76 { 79 if ( $handler_id != '____mfa-asgard_midcom.admin.user-user_edit_password' 80 && $this->_config->get('allow_manage_accounts')) 77 $data['asgard_toolbar']->add_item 78 ( 79 array 80 ( 81 MIDCOM_TOOLBAR_URL => "__mfa/asgard_midcom.admin.user/", 82 MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('midcom.admin.user'), 83 MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_person-new.png', 84 ), 85 $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX) 86 ); 87 88 if ( $handler_id !== '____mfa-asgard_midcom.admin.user-user_edit_password' 89 && $this->_config->get('allow_manage_accounts') 90 && $this->_person) 81 91 { 82 92 $data['asgard_toolbar']->add_item … … 94 104 } 95 105 96 97 98 106 /** 99 107 * Loads and prepares the schema database. … … 228 236 midcom_show_style('midcom-admin-user-generate-passwords'); 229 237 } 238 239 /** 240 * Internal helper for processing the batch change of passwords 241 * 242 * @access private 243 */ 244 function _process_batch_change() 245 { 246 if ( !isset($_POST['midcom_admin_user']) 247 || count($_POST['midcom_admin_user']) === 0) 248 { 249 return; 250 } 251 252 if (isset($_POST['f_cancel'])) 253 { 254 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), $_MIDCOM->i18n->get_string('cancelled', 'midcom')); 255 $_MIDCOM->relocate('__mfa/asgard_midcom.admin.user/'); 256 // This will exit 257 } 258 259 // Load the org.openpsa.mail class 260 $_MIDCOM->componentloader->load('org.openpsa.mail'); 261 262 // Set the mail commo parts 263 $mail = new org_openpsa_mail(); 264 $mail->from = $this->_config->get('message_sender'); 265 $mail->encoding = 'UTF-8'; 266 267 // Success switch 268 $success = true; 269 270 // Get the context prefix 271 $prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX); 272 273 // Change every user or continue to next on failure - failures will show UI messages 274 foreach ($_POST['midcom_admin_user'] as $id) 275 { 276 $person = new midcom_db_person($id); 277 278 // Check integrity 279 if ( !$person 280 || !$person->guid) 281 { 282 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('failed to get the user with id %s'), $id), 'error'); 283 $success = false; 284 continue; 285 } 286 287 // This shortcut is used in case of errors 288 $person_edit_url = "<a href=\"{$prefix}__mfa/asgard_midcom.admin.user/edit/{$person->guid}\">{$person->name}</a>"; 289 290 // Cannot send the email if address is not specified 291 if (!$person->email) 292 { 293 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('no email address defined for %s'), $person_edit_url), 'error'); 294 continue; 295 } 296 297 // Recipient 298 $mail->to = $person->email; 299 300 // Clean, unchanged message 301 $body = $_POST['body']; 302 $subject = $_POST['subject']; 303 304 // Store the old password 305 $person->set_parameter('midcom.admin.user', 'old_password', $person->password); 306 307 // Get a new password 308 $password = midcom_admin_user_plugin::generate_password(8); 309 310 // Replace the variables 311 foreach ($this->_request_data['variables'] as $key => $value) 312 { 313 // Replace the variables with personalized values 314 switch ($key) 315 { 316 case '__PASSWORD__': 317 $subject = str_replace($key, $password, $subject); 318 $body = str_replace($key, $password, $body); 319 break; 320 321 case '__FROM__': 322 $subject = str_replace($key, $this->_config->get('message_sender'), $subject); 323 $body = str_replace($key, $this->_config->get('message_sender'), $body); 324 break; 325 326 case '__LONGDATE__': 327 $subject = str_replace($key, strftime('%c'), $subject); 328 $body = str_replace($key, strftime('%c'), $body); 329 break; 330 331 case '__SHORTDATE__': 332 $subject = str_replace($key, strftime('%x'), $subject); 333 $body = str_replace($key, strftime('%x'), $body); 334 break; 335 336 case '__TIME__': 337 $subject = str_replace($key, strftime('%X'), $subject); 338 $body = str_replace($key, strftime('%X'), $body); 339 break; 340 341 default: 342 if (!isset($person->$key)) 343 { 344 continue; 345 } 346 $subject = str_replace($key, $person->$key, $subject); 347 $body = str_replace($key, $person->$key, $body); 348 } 349 } 350 351 // After the tedious replacing, strings are placed to the mailer 352 $mail->body = $body; 353 $mail->subject = $subject; 354 355 // Send the message 356 if ($mail->send()) 357 { 358 // Set the password 359 $person->password = "**{$password}"; 360 361 if (!$person->update()) 362 { 363 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('failed to update the password for %s'), $person_edit_url)); 364 $success = false; 365 } 366 } 367 else 368 { 369 // $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), sprintf($this->_l10n->get('failed to send the message to %s'), $person_edit_url), 'error'); 370 $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Failed to send the mail, SMTP returned error {$mail->get_error_message()}"); 371 // This will exit 372 } 373 } 374 375 // Show UI message on success 376 if ($success) 377 { 378 $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.user'), $this->_l10n->get('passwords updated and mail sent')); 379 } 380 381 // Relocate to the user administration front page 382 $_MIDCOM->relocate('__mfa/asgard_midcom.admin.user/'); 383 // This will exit 384 } 385 386 /** 387 * Batch process password change 388 * 389 * @access public 390 */ 391 function _handler_batch($handler_id, $args, &$data) 392 { 393 $_MIDCOM->auth->require_admin_user(); 394 395 // Set page title and default variables 396 $data['view_title'] = $this->_l10n->get('batch generate passwords'); 397 $data['variables'] = array 398 ( 399 '__FIRSTNAME__' => $this->_l10n->get('firstname'), 400 '__LASTNAME__' => $this->_l10n->get('lastname'), 401 '__USERNAME__' => $this->_l10n->get('username'), 402 '__EMAIL__' => $this->_l10n->get('email'), 403 '__PASSWORD__' => $this->_l10n->get('password'), 404 '__FROM__' => $this->_l10n->get('sender'), 405 '__LONGDATE__' => sprintf($this->_l10n->get('long dateformat (%s)'), strftime('%c')), 406 '__SHORTDATE__' => sprintf($this->_l10n->get('short dateformat (%s)'), strftime('%x')), 407 '__TIME__' => sprintf($this->_l10n->get('current time (%s)'), strftime('%X')), 408 ); 409 410 $this->_process_batch_change(); 411 412 413 if(isset($_GET['ajax'])) 414 { 415 return true; 416 } 417 418 // Prepare the toolbar and breadcrumb 419 midgard_admin_asgard_plugin::get_common_toolbar($data); 420 $this->_prepare_toolbar(&$data, $handler_id); 421 422 // Populate breadcrumb 423 $tmp = Array(); 424 $tmp[] = Array 425 ( 426 MIDCOM_NAV_URL => "__mfa/asgard_midcom.admin.user/", 427 MIDCOM_NAV_NAME => $this->_l10n->get('midcom.admin.user'), 428 ); 429 $tmp[] = Array 430 ( 431 MIDCOM_NAV_URL => '__mfa/asgard_midcom.admin.user/password/batch/', 432 MIDCOM_NAV_NAME => $this->_request_data['view_title'], 433 ); 434 $_MIDCOM->set_custom_context_data('midcom.helper.nav.breadcrumb', $tmp); 435 436 437 return true; 438 } 439 440 /** 441 * Show the batch password change form 442 * 443 * @access public 444 */ 445 function _show_batch($handler_id, &$data) 446 { 447 if (!isset($_GET['ajax'])) 448 { 449 midgard_admin_asgard_plugin::asgard_header(); 450 midcom_show_style('midcom-admin-user-password-nonajax-header'); 451 } 452 453 $data['message_subject'] = $this->_l10n->get($this->_config->get('message_subject')); 454 $data['message_body'] = $this->_l10n->get($this->_config->get('message_body')); 455 456 midcom_show_style('midcom-admin-user-password-email'); 457 458 if (!isset($_GET['ajax'])) 459 { 460 midcom_show_style('midcom-admin-user-passwords-list'); 461 midgard_admin_asgard_plugin::asgard_footer(); 462 } 463 } 230 464 } 231 465 ?> trunk/midcom/midcom.admin.user/locale/default.en.txt
r13506 r13510 4 4 ---LANGUAGE en 5 5 6 ---STRING Your password has been changed. Your new password is __PASSWORD__ 7 Your password has been changed. Your new password is __PASSWORD__ 8 ---STRINGEND 9 6 10 ---STRING add to group 7 11 Add to group … … 16 20 ---STRINGEND 17 21 22 ---STRING batch generate passwords 23 Batch generate passwords 24 ---STRINGEND 25 26 ---STRING change passwords 27 Change passwords 28 ---STRINGEND 29 18 30 ---STRING choose action 19 31 Choose action … … 32 44 ---STRINGEND 33 45 46 ---STRING current time (%s) 47 Current time (%s) 48 ---STRINGEND 49 34 50 ---STRING edit %s 35 51 Edit %s … … 44 60 ---STRINGEND 45 61 62 ---STRING empty selection 63 Empty selection 64 ---STRINGEND 65 46 66 ---STRING enable ajax in toolbar 47 67 Enable AJAX features of centralized toolbar … … 60 80 ---STRINGEND 61 81 82 ---STRING failed to send the message to %s 83 Failed to send the message to %s 84 ---STRINGEND 85 86 ---STRING failed to update the password for %s 87 Failed to update the password for %s 88 ---STRINGEND 89 62 90 ---STRING firstname 63 91 Firstname … … 76 104 ---STRINGEND 77 105 106 ---STRING generate new passwords 107 Generate new passwords 108 ---STRINGEND 109 78 110 ---STRING generate passwords 79 111 Generate passwords … … 96 128 ---STRINGEND 97 129 130 ---STRING long dateformat 131 Long dateformat 132 ---STRINGEND 133 134 ---STRING long dateformat (%s) 135 Long dateformat (%s) 136 ---STRINGEND 137 98 138 ---STRING maximum %s 99 139 Maximum %s … … 104 144 ---STRINGEND 105 145 146 ---STRING message 147 Message 148 ---STRINGEND 149 106 150 ---STRING midcom.admin.user 107 151 User management … … 116 160 ---STRINGEND 117 161 162 ---STRING no email address defined for %s 163 No email address defined for %s 164 ---STRINGEND 165 118 166 ---STRING official 119 167 Official name … … 124 172 ---STRINGEND 125 173 174 ---STRING password 175 Password 176 ---STRINGEND 177 126 178 ---STRING password length 127 179 Password length … … 132 184 ---STRINGEND 133 185 186 ---STRING passwords updated and mail sent 187 Passwords updated and mail sent 188 ---STRINGEND 189 134 190 ---STRING person %s saved 135 191 User %s saved 136 192 ---STRINGEND 137 193 194 ---STRING personalized equal 195 Personalized equal 196 ---STRINGEND 197 138 198 ---STRING postcode 139 199 Postcode … … 144 204 ---STRINGEND 145 205 206 ---STRING prevent repeating characters 207 Prevent repeating characters 208 ---STRINGEND 209 146 210 ---STRING prevent similar characters 147 211 Prevent similar characters … … 156 220 ---STRINGEND 157 221 222 ---STRING sender 223 Sender 224 ---STRINGEND 225 226 ---STRING short dateformat (%s) 227 Short dateformat (%s) 228 ---STRINGEND 229 230 ---STRING string 231 String 232 ---STRINGEND 233 234 ---STRING subject 235 Subject 236 ---STRINGEND 237 158 238 ---STRING the following fields will be searched: %s 159 239 The following fields will be searched: %s … … 172 252 ---STRINGEND 173 253 254 ---STRING variable 255 Variable 256 ---STRINGEND 257 174 258 ---STRING workphone 175 259 Work phone 176 260 ---STRINGEND 177 261 178 ---STRING prevent repeating characters 179 Prevent repeating characters 180 ---STRINGEND 181 262 ---STRING write the message that will be sent to the recipients 263 Write the message that will be sent to the recipients 264 ---STRINGEND 265 266 ---STRING your password has been changed 267 Your password has been changed 268 ---STRINGEND 269 270 ---STRING passwords will be sent to the following users 271 Passwords will be sent to the following users 272 ---STRINGEND 273 trunk/midcom/midcom.admin.user/locale/default.fi.txt
r13506 r13510 4 4 ---LANGUAGE fi 5 5 6 ---STRING Your password has been changed. Your new password is __PASSWORD__ 7 Salasanasi on vaihdettu. Uusi salasanasi on __PASSWORD__ 8 ---STRINGEND 9 6 10 ---STRING add to group 7 11 LisÀÀ ryhmÀÀn … … 16 20 ---STRINGEND 17 21 22 ---STRING batch generate passwords 23 Massamuutokset salasanoihin 24 ---STRINGEND 25 26 ---STRING change passwords 27 Muuta salasanat 28 ---STRINGEND 29 18 30 ---STRING choose action 19 31 Valitse toiminto … … 32 44 ---STRINGEND 33 45 46 ---STRING current time (%s) 47 Kellonaika (%s) 48 ---STRINGEND 49 34 50 ---STRING edit %s 35 51 Muokkaa kohdetta %s … … 44 60 ---STRINGEND 45 61 62 ---STRING empty selection 63 TyhjÀ valinta 64 ---STRINGEND 65 46 66 ---STRING enable ajax in toolbar 47 67 KÀytÀ työkalupalkin AJAX-ominaisuuksia … … 60 80 ---STRINGEND 61 81 82 ---STRING failed to send the message to %s 83 Viestin lÀhettÀminen kÀyttÀjÀlle %s epÀonnistui 84 ---STRINGEND 85 86 ---STRING failed to update the password for %s 87 Salasanan tallentaminen henkilölle %s epÀonnistui 88 ---STRINGEND 89 62 90 ---STRING firstname 63 91 Etunimi … … 76 104 ---STRINGEND 77 105 106 ---STRING generate new passwords 107 Luo uudet salasanat 108 ---STRINGEND 109 110 ---STRING generate passwords 111 Luo salasanoja 112 ---STRINGEND 113 78 114 ---STRING go 79 115 Hae … … 92 128 ---STRINGEND 93 129 130 ---STRING long dateformat 131 PitkÀ aikamuoto 132 ---STRINGEND 133 134 ---STRING long dateformat (%s) 135 PitkÀ aikamuoto (%s) 136 ---STRINGEND 137 94 138 ---STRING maximum %s 95 139 Korkeintaan %s … … 100 144 ---STRINGEND 101 145 146 ---STRING message 147 Viesti 148 ---STRINGEND 149 102 150 ---STRING midcom.admin.user 103 151 KÀyttÀjien hallinta … … 112 160 ---STRINGEND 113 161 162 ---STRING no email address defined for %s 163 SÀhköpostiosoitetta ei ole mÀÀritetty kÀyttÀjÀlle %s 164 ---STRINGEND 165 114 166 ---STRING official 115 167 Virallinen nimi … … 120 172 ---STRINGEND 121 173 174 ---STRING password 175 Salasana 176 ---STRINGEND 177 122 178 ---STRING password length 123 179 Salasanan pituus … … 128 184 ---STRINGEND 129 185 186 ---STRING passwords updated and mail sent 187 Salasanat on pÀivitetty ja posti lÀhetetty 188 ---STRINGEND 189 130 190 ---STRING person %s saved 131 191 KÀyttÀjÀ %s tallennettu 132 192 ---STRINGEND 133 193 194 ---STRING personalized equal 195 Personoitu vastine 196 ---STRINGEND 197 134 198 ---STRING postcode 135 199 Postinumero … … 140 204 ---STRINGEND 141 205 206 ---STRING prevent repeating characters 207 EstÀ samojen merkkien toistuminen 208 ---STRINGEND 209 142 210 ---STRING prevent similar characters 143 211 EstÀ samanlaiset merkit … … 152 220 ---STRINGEND 153 221 222 ---STRING sender 223 LÀhettÀjÀ 224 ---STRINGEND 225 226 ---STRING short dateformat (%s) 227 Lyhyt aikamuoto 228 ---STRINGEND 229 230 ---STRING string 231 Merkkiketju 232 ---STRINGEND 233 234 ---STRING subject 235 Otsikko 236 ---STRINGEND 237 154 238 ---STRING the following fields will be searched: %s 155 239 Haku tehdÀÀn seuraavista kentistÀ: %s … … 168 252 ---STRINGEND 169 253 254 ---STRING variable 255 Muuttuja 256 ---STRINGEND 257 170 258 ---STRING workphone 171 259 Työpuhelin 172 260 ---STRINGEND 173 261 174 ---STRING prevent repeating characters 175 EstÀ samojen merkkien toistuminen 176 ---STRINGEND 177 262 ---STRING write the message that will be sent to the recipients 263 Kirjoita viesti, joka lÀhetetÀÀn vastaanottajille 264 ---STRINGEND 265 266 ---STRING your password has been changed 267 Salasanasi on vaihdettu 268 ---STRINGEND 269 270 ---STRING passwords will be sent to the following users 271 Salasanat lÀhetetÀÀn seuraaville kÀyttÀjille 272 ---STRINGEND 273 trunk/midcom/midcom.admin.user/plugin.php
r13506 r13510 68 68 * Generate random passwords 69 69 * 70 * Match / /user-editor/password/70 * Match /user-editor/password/ 71 71 */ 72 72 'user_passwords' => array … … 74 74 'handler' => array ('midcom_admin_user_handler_user_edit', 'passwords'), 75 75 'fixed_args' => array ('password'), 76 ), 77 /** 78 * Generate random passwords 79 * 80 * Match /user-editor/password/email/ 81 */ 82 'user_passwords_batch' => array 83 ( 84 'handler' => array ('midcom_admin_user_handler_user_edit', 'batch'), 85 'fixed_args' => array ('password', 'batch'), 76 86 ), 77 87 /** … … 153 163 ); 154 164 } 165 166 /** 167 * Static method for generating one password 168 * 169 * @access static public 170 * @param int $length 171 */ 172 function generate_password($length, $no_similars = true, $strong = true) 173 { 174 $similars = array 175 ( 176 'I', 'l', '1', '0', 'O', 177 ); 178 179 $string = ''; 180 for ($x = 0; $x < $length; $x++) 181 { 182 $rand = (int) rand(48, 122); 183 $char = chr($rand); 184 185 $k = 0; 186 187 while ( !ereg('[a-zA-Z0-9]', $char) 188 || ( $strong 189 && strlen($string) > 0 190 && strstr($string, $char)) 191 || ( $no_similars 192 && in_array($char, $similars))) 193 { 194 $rand = (int) rand(48, 122); 195 $char = chr($rand); 196 197 $k++; 198 } 199 $string .= $char; 200 } 201 202 return $string; 203 } 155 204 } 156 205 ?> trunk/midcom/midcom.admin.user/static/usermgmt.css
r13506 r13510 54 54 } 55 55 56 #midcom_admin_user_passwords label 56 #midcom_admin_user_passwords label, 57 #midcom_admin_user_action_passwords label 57 58 { 59 font-weight: bold; 58 60 display: block; 61 margin-top: 1em; 59 62 } 63 64 #midcom_admin_user_action_passwords h1 65 { 66 font-size: 120%; 67 } 68 69 #midcom_admin_user_email_body 70 { 71 width: 20em; 72 height: 15em; 73 } trunk/midcom/midcom.admin.user/style/midcom-admin-user-generate-passwords.php
r13506 r13510 5 5 $max_amount = 100; 6 6 $max_length = 16; 7 8 $similars = array9 (10 'I', 'l', '1', '0', 'O',11 );12 7 13 8 if (isset($_GET['f_submit'])) … … 40 35 <label for="similar_characters"> 41 36 <input type="checkbox" id="similar_characters" name="no_similars" value="1" <?php if ($no_similars) { echo ' checked="checked"'; } ?> /> 42 <span class="label"><?php echo $data['l10n']->get('prevent similar characters'); ?> (<em> <?php echo implode(', ', $similars); ?></em>)</span>37 <span class="label"><?php echo $data['l10n']->get('prevent similar characters'); ?> (<em>I, l, 1, 0, O</em>)</span> 43 38 </label> 44 39 <input type="submit" name="f_submit" value="<?php echo $data['l10n']->get('generate'); ?>" /> … … 73 68 for ($i = 0; $i < $n; $i++) 74 69 { 75 $string = ''; 76 for ($x = 0; $x < $length; $x++) 77 { 78 $rand = (int) rand(48, 122); 79 $char = chr($rand); 80 81 $k = 0; 82 83 while ( !ereg('[a-zA-Z0-9]', $char) 84 || ( $strong 85 && strlen($string) > 0 86 && strstr($string, $char)) 87 || ( $no_similars 88 && in_array($char, $similars))) 89 { 90 $rand = (int) rand(48, 122); 91 $char = chr($rand); 92 93 $k++; 94 // echo "[{$k}:{$char}]"; 95 } 96 97 echo $char; 98 // echo " ({$rand}) "; 99 $string .= $char; 100 } 70 echo midcom_admin_user_plugin::generate_password($length, $no_similars, $strong); 101 71 echo "\n"; 102 72 } trunk/midcom/midcom.admin.user/style/midcom-admin-user-personlist-footer.php
r13077 r13510 1 1 <?php 2 $prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX); 3 2 4 if (count($data['persons']) > 0) 3 5 { … … 16 18 <td> </td> 17 19 <td colspan="<?php echo count($data['list_fields']); ?>"> 18 <select name="midcom_admin_user_action"<?php echo $disabled; ?>>20 <select id="midcom_admin_user_action" name="midcom_admin_user_action"<?php echo $disabled; ?>> 19 21 <option value=""><?php echo $_MIDCOM->i18n->get_string('choose action', 'midcom.admin.user'); ?></option> 20 22 <?php … … 27 29 ?> 28 30 <option value="groupadd" onclick="javascript:document.getElementById('midcom_admin_user_group').style.display='inline';"><?php echo $_MIDCOM->i18n->get_string('add to group', 'midcom.admin.user'); ?></option> 31 <option value="passwords"><?php echo $_MIDCOM->i18n->get_string('generate new passwords', 'midcom.admin.user'); ?></option> 29 32 </select> 30 33 <select name="midcom_admin_user_group" id="midcom_admin_user_group" style="display: none;"<?php echo $disabled; ?>> … … 46 49 </table> 47 50 </form> 51 <script type="text/javascript"> 52 // <![CDATA[ 53 $j('#midcom_admin_user_action').change(function() 54 { 55 if (this.value == 'passwords') 56 { 57 $j('<div></div>') 58 .attr('id', 'midcom_admin_user_action_passwords') 59 .appendTo('#midcom_admin_user_batch_process'); 60 61 // Load the form for outputting the style 62 $j('#midcom_admin_user_action_passwords').load('&(prefix);__mfa/asgard_midcom.admin.user/password/batch/?ajax×tamp=<?php echo time(); ?>'); 63 64 $j('#midcom_admin_user_batch_process').submit(function() 65 { 66 var action = '&(prefix);__mfa/asgard_midcom.admin.user/password/batch/?ajax'; 67 $j(this).attr('action', action); 68 }); 69 } 70 else 71 { 72 $j('#midcom_admin_user_action_passwords').css('display', 'none'); 73 74 // Return the original submit functionality 75 $j('#midcom_admin_user_batch_process').submit(function() 76 { 77 var action = '&(prefix);__mfa/asgard_midcom.admin.user/'; 78 $j(this).attr('action', action); 79 80 return true; 81 }); 82 } 83 }); 84 // ]]> 85 </script> 48 86 <?php 49 87 } trunk/midcom/midcom.admin.user/style/midcom-admin-user-personlist-header.php
r13077 r13510 22 22 $data['enabled'] = 0; 23 23 ?> 24 <form method="post" >24 <form method="post" id="midcom_admin_user_batch_process" action="&(_MIDGARD['uri']);"> 25 25 <table class="midcom_admin_user_search_results"> 26 26 <thead>
