password_encryption_algorithm; if($algo == 'none') { $this->debugMessage('Password encryption disabled'); return; } // Are there members with a clear text password? $members = Member::get()->where(array( '"Member"."PasswordEncryption"' => 'none', '"Member"."Password" IS NOT NULL' )); if(!$members) { $this->debugMessage('No passwords to encrypt'); return; } // Encrypt the passwords... $this->debugMessage('Encrypting all passwords'); $this->debugMessage(sprintf( 'The passwords will be encrypted using the %s algorithm', $algo )); foreach($members as $member) { // Force the update of the member record, as new passwords get // automatically encrypted according to the settings, this will do all // the work for us $member->PasswordEncryption = $algo; $member->forceChange(); $member->write(); $this->debugMessage(sprintf('Encrypted credentials for member #%d;', $member->ID)); } } /** * @todo This should really be taken care of by the testing framework */ protected function debugMessage($msg) { if(class_exists('SapphireTest', false) && !SapphireTest::is_running_test()) { Debug::message($msg); } } }