Changeset 13510

Show
Ignore:
Timestamp:
11/20/07 13:44:23 (1 year ago)
Author:
adrenalin
Message:

Added batch processing for new passwords

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.admin.user/config/config.inc

    r13076 r13510  
    2222    'city',  
    2323), 
     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  
    111111        $data['search_fields'] = $this->_config->get('search_fields'); 
    112112        $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        } 
    113131         
    114132        if (   isset($_POST['midcom_admin_user']) 
     
    147165                            } 
    148166                        } 
     167                        break; 
    149168                } 
    150169            } 
  • trunk/midcom/midcom.admin.user/handler/user/edit.php

    r13506 r13510  
    3030    function _on_initialize() 
    3131    { 
    32  
    3332        $this->_l10n = $_MIDCOM->i18n->get_l10n('midcom.admin.user'); 
    3433        $this->_request_data['l10n'] = $this->_l10n; 
     
    4544 
    4645        midgard_admin_asgard_plugin::prepare_plugin($this->_l10n->get('midcom.admin.user'),$this->_request_data); 
    47  
    4846    } 
    4947     
     
    7775    function _prepare_toolbar(&$data,$handler_id) 
    7876    { 
    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) 
    8191        { 
    8292            $data['asgard_toolbar']->add_item 
     
    94104    } 
    95105 
    96  
    97  
    98106    /** 
    99107     * Loads and prepares the schema database. 
     
    228236        midcom_show_style('midcom-admin-user-generate-passwords'); 
    229237    } 
     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    } 
    230464} 
    231465?> 
  • trunk/midcom/midcom.admin.user/locale/default.en.txt

    r13506 r13510  
    44---LANGUAGE en 
    55 
     6---STRING Your password has been changed. Your new password is __PASSWORD__ 
     7Your password has been changed. Your new password is __PASSWORD__ 
     8---STRINGEND 
     9 
    610---STRING add to group 
    711Add to group 
     
    1620---STRINGEND 
    1721 
     22---STRING batch generate passwords 
     23Batch generate passwords 
     24---STRINGEND 
     25 
     26---STRING change passwords 
     27Change passwords 
     28---STRINGEND 
     29 
    1830---STRING choose action 
    1931Choose action 
     
    3244---STRINGEND 
    3345 
     46---STRING current time (%s) 
     47Current time (%s) 
     48---STRINGEND 
     49 
    3450---STRING edit %s 
    3551Edit %s 
     
    4460---STRINGEND 
    4561 
     62---STRING empty selection 
     63Empty selection 
     64---STRINGEND 
     65 
    4666---STRING enable ajax in toolbar 
    4767Enable AJAX features of centralized toolbar 
     
    6080---STRINGEND 
    6181 
     82---STRING failed to send the message to %s 
     83Failed to send the message to %s 
     84---STRINGEND 
     85 
     86---STRING failed to update the password for %s 
     87Failed to update the password for %s 
     88---STRINGEND 
     89 
    6290---STRING firstname 
    6391Firstname 
     
    76104---STRINGEND 
    77105 
     106---STRING generate new passwords 
     107Generate new passwords 
     108---STRINGEND 
     109 
    78110---STRING generate passwords 
    79111Generate passwords 
     
    96128---STRINGEND 
    97129 
     130---STRING long dateformat 
     131Long dateformat 
     132---STRINGEND 
     133 
     134---STRING long dateformat (%s) 
     135Long dateformat (%s) 
     136---STRINGEND 
     137 
    98138---STRING maximum %s 
    99139Maximum %s 
     
    104144---STRINGEND 
    105145 
     146---STRING message 
     147Message 
     148---STRINGEND 
     149 
    106150---STRING midcom.admin.user 
    107151User management 
     
    116160---STRINGEND 
    117161 
     162---STRING no email address defined for %s 
     163No email address defined for %s 
     164---STRINGEND 
     165 
    118166---STRING official 
    119167Official name 
     
    124172---STRINGEND 
    125173 
     174---STRING password 
     175Password 
     176---STRINGEND 
     177 
    126178---STRING password length 
    127179Password length 
     
    132184---STRINGEND 
    133185 
     186---STRING passwords updated and mail sent 
     187Passwords updated and mail sent 
     188---STRINGEND 
     189 
    134190---STRING person %s saved 
    135191User %s saved 
    136192---STRINGEND 
    137193 
     194---STRING personalized equal 
     195Personalized equal 
     196---STRINGEND 
     197 
    138198---STRING postcode 
    139199Postcode 
     
    144204---STRINGEND 
    145205 
     206---STRING prevent repeating characters 
     207Prevent repeating characters 
     208---STRINGEND 
     209 
    146210---STRING prevent similar characters 
    147211Prevent similar characters 
     
    156220---STRINGEND 
    157221 
     222---STRING sender 
     223Sender 
     224---STRINGEND 
     225 
     226---STRING short dateformat (%s) 
     227Short dateformat (%s) 
     228---STRINGEND 
     229 
     230---STRING string 
     231String 
     232---STRINGEND 
     233 
     234---STRING subject 
     235Subject 
     236---STRINGEND 
     237 
    158238---STRING the following fields will be searched: %s 
    159239The following fields will be searched: %s 
     
    172252---STRINGEND 
    173253 
     254---STRING variable 
     255Variable 
     256---STRINGEND 
     257 
    174258---STRING workphone 
    175259Work phone 
    176260---STRINGEND 
    177261 
    178 ---STRING prevent repeating characters 
    179 Prevent repeating characters 
    180 ---STRINGEND 
    181  
     262---STRING write the message that will be sent to the recipients 
     263Write the message that will be sent to the recipients 
     264---STRINGEND 
     265 
     266---STRING your password has been changed 
     267Your password has been changed 
     268---STRINGEND 
     269 
     270---STRING passwords will be sent to the following users 
     271Passwords will be sent to the following users 
     272---STRINGEND 
     273 
  • trunk/midcom/midcom.admin.user/locale/default.fi.txt

    r13506 r13510  
    44---LANGUAGE fi 
    55 
     6---STRING Your password has been changed. Your new password is __PASSWORD__ 
     7Salasanasi on vaihdettu. Uusi salasanasi on __PASSWORD__ 
     8---STRINGEND 
     9 
    610---STRING add to group 
    711LisÀÀ ryhmÀÀn 
     
    1620---STRINGEND 
    1721 
     22---STRING batch generate passwords 
     23Massamuutokset salasanoihin 
     24---STRINGEND 
     25 
     26---STRING change passwords 
     27Muuta salasanat 
     28---STRINGEND 
     29 
    1830---STRING choose action 
    1931Valitse toiminto 
     
    3244---STRINGEND 
    3345 
     46---STRING current time (%s) 
     47Kellonaika (%s) 
     48---STRINGEND 
     49 
    3450---STRING edit %s 
    3551Muokkaa kohdetta %s 
     
    4460---STRINGEND 
    4561 
     62---STRING empty selection 
     63TyhjÀ valinta 
     64---STRINGEND 
     65 
    4666---STRING enable ajax in toolbar 
    4767KÀytÀ työkalupalkin AJAX-ominaisuuksia 
     
    6080---STRINGEND 
    6181 
     82---STRING failed to send the message to %s 
     83Viestin lÀhettÀminen kÀyttÀjÀlle %s epÀonnistui 
     84---STRINGEND 
     85 
     86---STRING failed to update the password for %s 
     87Salasanan tallentaminen henkilölle %s epÀonnistui 
     88---STRINGEND 
     89 
    6290---STRING firstname 
    6391Etunimi 
     
    76104---STRINGEND 
    77105 
     106---STRING generate new passwords 
     107Luo uudet salasanat 
     108---STRINGEND 
     109 
     110---STRING generate passwords 
     111Luo salasanoja 
     112---STRINGEND 
     113 
    78114---STRING go 
    79115Hae 
     
    92128---STRINGEND 
    93129 
     130---STRING long dateformat 
     131PitkÀ aikamuoto 
     132---STRINGEND 
     133 
     134---STRING long dateformat (%s) 
     135PitkÀ aikamuoto (%s) 
     136---STRINGEND 
     137 
    94138---STRING maximum %s 
    95139Korkeintaan %s 
     
    100144---STRINGEND 
    101145 
     146---STRING message 
     147Viesti 
     148---STRINGEND 
     149 
    102150---STRING midcom.admin.user 
    103151KÀyttÀjien hallinta 
     
    112160---STRINGEND 
    113161 
     162---STRING no email address defined for %s 
     163SÀhköpostiosoitetta ei ole mÀÀritetty kÀyttÀjÀlle %s 
     164---STRINGEND 
     165 
    114166---STRING official 
    115167Virallinen nimi 
     
    120172---STRINGEND 
    121173 
     174---STRING password 
     175Salasana 
     176---STRINGEND 
     177 
    122178---STRING password length 
    123179Salasanan pituus 
     
    128184---STRINGEND 
    129185 
     186---STRING passwords updated and mail sent 
     187Salasanat on pÀivitetty ja posti lÀhetetty 
     188---STRINGEND 
     189 
    130190---STRING person %s saved 
    131191KÀyttÀjÀ %s tallennettu 
    132192---STRINGEND 
    133193 
     194---STRING personalized equal 
     195Personoitu vastine 
     196---STRINGEND 
     197 
    134198---STRING postcode 
    135199Postinumero 
     
    140204---STRINGEND 
    141205 
     206---STRING prevent repeating characters 
     207EstÀ samojen merkkien toistuminen 
     208---STRINGEND 
     209 
    142210---STRING prevent similar characters 
    143211EstÀ samanlaiset merkit 
     
    152220---STRINGEND 
    153221 
     222---STRING sender 
     223LÀhettÀjÀ 
     224---STRINGEND 
     225 
     226---STRING short dateformat (%s) 
     227Lyhyt aikamuoto 
     228---STRINGEND 
     229 
     230---STRING string 
     231Merkkiketju 
     232---STRINGEND 
     233 
     234---STRING subject 
     235Otsikko 
     236---STRINGEND 
     237 
    154238---STRING the following fields will be searched: %s 
    155239Haku tehdÀÀn seuraavista kentistÀ: %s 
     
    168252---STRINGEND 
    169253 
     254---STRING variable 
     255Muuttuja 
     256---STRINGEND 
     257 
    170258---STRING workphone 
    171259Työpuhelin 
    172260---STRINGEND 
    173261 
    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 
     263Kirjoita viesti, joka lÀhetetÀÀn vastaanottajille 
     264---STRINGEND 
     265 
     266---STRING your password has been changed 
     267Salasanasi on vaihdettu 
     268---STRINGEND 
     269 
     270---STRING passwords will be sent to the following users 
     271Salasanat lÀhetetÀÀn seuraaville kÀyttÀjille 
     272---STRINGEND 
     273 
  • trunk/midcom/midcom.admin.user/plugin.php

    r13506 r13510  
    6868             * Generate random passwords 
    6969             *  
    70              * Match //user-editor/password/ 
     70             * Match /user-editor/password/ 
    7171             */ 
    7272            'user_passwords' => array 
     
    7474                'handler' => array ('midcom_admin_user_handler_user_edit', 'passwords'), 
    7575                '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'), 
    7686            ), 
    7787            /** 
     
    153163        ); 
    154164    } 
     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    } 
    155204} 
    156205?> 
  • trunk/midcom/midcom.admin.user/static/usermgmt.css

    r13506 r13510  
    5454} 
    5555 
    56 #midcom_admin_user_passwords label 
     56#midcom_admin_user_passwords label, 
     57#midcom_admin_user_action_passwords label 
    5758{ 
     59  font-weight: bold; 
    5860  display: block; 
     61  margin-top: 1em; 
    5962} 
     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  
    55$max_amount = 100; 
    66$max_length = 16; 
    7  
    8 $similars = array 
    9 ( 
    10     'I', 'l', '1', '0', 'O', 
    11 ); 
    127 
    138if (isset($_GET['f_submit'])) 
     
    4035            <label for="similar_characters"> 
    4136                <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> 
    4338            </label> 
    4439            <input type="submit" name="f_submit" value="<?php echo $data['l10n']->get('generate'); ?>" /> 
     
    7368    for ($i = 0; $i < $n; $i++) 
    7469    { 
    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); 
    10171        echo "\n"; 
    10272    } 
  • trunk/midcom/midcom.admin.user/style/midcom-admin-user-personlist-footer.php

    r13077 r13510  
    11<?php 
     2$prefix = $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX); 
     3 
    24if (count($data['persons']) > 0) 
    35{ 
     
    1618                <td>&nbsp;</td> 
    1719                <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; ?>> 
    1921                        <option value=""><?php echo $_MIDCOM->i18n->get_string('choose action', 'midcom.admin.user'); ?></option> 
    2022                        <?php 
     
    2729                        ?> 
    2830                        <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> 
    2932                    </select> 
    3033                    <select name="midcom_admin_user_group" id="midcom_admin_user_group" style="display: none;"<?php echo $disabled; ?>> 
     
    4649    </table> 
    4750    </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&timestamp=<?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> 
    4886    <?php 
    4987} 
  • trunk/midcom/midcom.admin.user/style/midcom-admin-user-personlist-header.php

    r13077 r13510  
    2222    $data['enabled'] = 0; 
    2323    ?> 
    24     <form method="post"
     24    <form method="post" id="midcom_admin_user_batch_process" action="&(_MIDGARD['uri']);"
    2525    <table class="midcom_admin_user_search_results"> 
    2626        <thead>