Index: branches/unlabeled/unlabeled-1.68.2/core/units/users/users_event_handler.php =================================================================== diff -u -r6854 -r6918 --- branches/unlabeled/unlabeled-1.68.2/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 6854) +++ branches/unlabeled/unlabeled-1.68.2/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 6918) @@ -12,6 +12,7 @@ $permissions = Array( // admin 'OnSetPersistantVariable' => Array('self' => 'view'), // because setting to logged in user only + 'OnUpdateRootPassword' => Array('self' => true), // because setting to logged in user only // front 'OnRefreshForm' => Array('self' => true), @@ -1034,6 +1035,41 @@ } return parent::getPassedID($event); } + + /** + * Allows to change root password + * + * @param kEvent $event + */ + function OnUpdateRootPassword(&$event) + { + $user_id = $this->Application->RecallVar('user_id'); + if ($user_id != -1) { + // not "root" can't change root's password via this event + return false; + } + + $object =& $event->getObject( Array('skip_autoload' => true) ); + /* @var $object UsersItem */ + + $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); + if ($items_info) { + list ($id, $field_values) = each($items_info); + $object->SetDefaultValues(); + $object->SetDBField('RootPassword', $this->Application->ConfigValue('RootPass')); + $object->Fields['RootPassword']['salt'] = 'b38'; + + $object->SetFieldsFromHash($field_values); + $status = $object->Validate(); + if ($status) { + // validation on, password match too + } + else { + $event->status = erFAIL; + $event->redirect = false; + } + } + } } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.2.8/core/kernel/utility/formatters/password_formatter.php =================================================================== diff -u -r6435 -r6918 --- branches/unlabeled/unlabeled-1.2.8/core/kernel/utility/formatters/password_formatter.php (.../password_formatter.php) (revision 6435) +++ branches/unlabeled/unlabeled-1.2.8/core/kernel/utility/formatters/password_formatter.php (.../password_formatter.php) (revision 6918) @@ -11,6 +11,9 @@ { $add_fields = Array(); $options = Array('master_field' => $field_name, 'formatter'=>'kPasswordFormatter'); + if (isset($field_options['encryption_method'])) { + $options['encryption_method'] = $field_options['encryption_method']; + } $add_fields[ $field_options['verify_field'] ] = $options; $add_fields[$field_name.'_plain'] = Array('type'=>'string', 'error_field'=>$field_name); @@ -52,12 +55,13 @@ if( getArrayValue($object->Fields[$password_field], 'verify_field_set') && getArrayValue($object->Fields[$verify_field], 'master_field_set') ) { + $salt = isset($object->Fields[$password_field]['salt']) ? $object->Fields[$password_field]['salt'] : ''; $new_password = $object->GetDBField($password_field.'_plain'); $verify_password = $object->GetDBField($verify_field.'_plain'); if($new_password == '' && $verify_password == '') { - if( $object->GetDBField($password_field) != $this->EncryptPassword('') ) + if( $object->GetDBField($password_field) != $this->EncryptPassword('', $salt) ) { if ($options['encryption_method'] == 'plain') return $value; return $this->EncryptPassword($value); @@ -90,12 +94,15 @@ if($value == '') return $object->GetDBField($field_name); if ($options['encryption_method'] == 'plain') return $value; - return $this->EncryptPassword($value); + return $this->EncryptPassword($value, $salt); } function EncryptPassword($value, $salt=null) { - if (!isset($salt)) return md5($value); + if (!isset($salt) || !$salt) { + // if empty salt, assume, that it's not passed at all + return md5($value); + } return md5(md5($value).$salt); } } \ No newline at end of file Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/users/user_edit_password.tpl =================================================================== diff -u --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/users/user_edit_password.tpl (revision 0) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/users/user_edit_password.tpl (revision 6918) @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + +
+ + + \ No newline at end of file Index: branches/unlabeled/unlabeled-1.32.2/core/units/users/users_config.php =================================================================== diff -u -r6698 -r6918 --- branches/unlabeled/unlabeled-1.32.2/core/units/users/users_config.php (.../users_config.php) (revision 6698) +++ branches/unlabeled/unlabeled-1.32.2/core/units/users/users_config.php (.../users_config.php) (revision 6918) @@ -172,6 +172,7 @@ 'ValidateLogin' => Array('type'=>'string','default'=>''), 'SubscribeEmail' => Array('type'=>'string','default'=>''), 'PrimaryGroup' => Array('type' => 'string', 'default' => ''), + 'RootPassword' => Array('type' => 'string', 'formatter' => 'kPasswordFormatter', 'encryption_method' => 'md5', 'verify_field' => 'VerifyRootPassword', 'skip_empty' => 1, 'default' => md5('') ), ), 'Grids' => Array( Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/users/root_edit_password.tpl =================================================================== diff -u --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/users/root_edit_password.tpl (revision 0) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/users/root_edit_password.tpl (revision 6918) @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ + + \ No newline at end of file