diff --git a/app/code/core/Mage/Admin/Model/User.php b/app/code/core/Mage/Admin/Model/User.php index b10e26a982f..ea19bfd9e31 100644 --- a/app/code/core/Mage/Admin/Model/User.php +++ b/app/code/core/Mage/Admin/Model/User.php @@ -733,17 +733,21 @@ protected function _getDateNow($dayOnly = false) * You can declare additional emails in Mage_Core general/additional_notification_emails/admin_user_create node. * * @param Mage_Admin_Model_User $user + * @param string|false $receiverEmail An optional receiver email address for the notification. Overrides default and additional emails. * @return $this */ - public function sendAdminNotification($user) + public function sendAdminNotification($user, $receiverEmail = false) { // define general contact Name and Email $generalContactName = Mage::getStoreConfig('trans_email/ident_general/name'); $generalContactEmail = Mage::getStoreConfig('trans_email/ident_general/email'); - // collect general and additional emails - $emails = $this->getUserCreateAdditionalEmail(); - $emails[] = $generalContactEmail; + // collect general and additional emails unless overridden + if ($receiverEmail && filter_var($receiverEmail, FILTER_VALIDATE_EMAIL)) { + $emails = [$receiverEmail]; + } else { + $emails = array_merge($this->getUserCreateAdditionalEmail(), [$generalContactEmail]); + } /** @var Mage_Core_Model_Email_Template_Mailer $mailer */ $mailer = Mage::getModel('core/email_template_mailer'); diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Email/Addressorempty.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Email/Addressorempty.php new file mode 100644 index 00000000000..8364dce4e60 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Email/Addressorempty.php @@ -0,0 +1,32 @@ +getValue(); + if ($value && !Zend_Validate::is($value, 'EmailAddress')) { + Mage::throwException(Mage::helper('adminhtml')->__('Invalid email address "%s".', $value)); + } + return $this; + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php index c2fa224a18f..a15d01487d4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php @@ -151,8 +151,9 @@ public function saveAction() try { $model->save(); // Send notification to General and additional contacts (if declared) that a new admin user was created. - if (Mage::getStoreConfigFlag('admin/security/crate_admin_user_notification') && $isNew) { - Mage::getModel('admin/user')->sendAdminNotification($model); + if (Mage::getStoreConfigFlag('admin/security/create_admin_user_notification') && $isNew) { + $contactEmail = Mage::getStoreConfig('admin/security/create_admin_user_notification_email'); + Mage::getModel('admin/user')->sendAdminNotification($model, $contactEmail); } if ($uRoles = $this->getRequest()->getParam('roles', false)) { if (is_array($uRoles) && (count($uRoles) >= 1)) { diff --git a/app/code/core/Mage/Core/etc/config.xml b/app/code/core/Mage/Core/etc/config.xml index d7ce041219d..3673dd77475 100644 --- a/app/code/core/Mage/Core/etc/config.xml +++ b/app/code/core/Mage/Core/etc/config.xml @@ -17,7 +17,7 @@ - 1.6.0.10 + 1.6.0.11 diff --git a/app/code/core/Mage/Core/etc/system.xml b/app/code/core/Mage/Core/etc/system.xml index 489b1e6fcf2..e46355cfc89 100644 --- a/app/code/core/Mage/Core/etc/system.xml +++ b/app/code/core/Mage/Core/etc/system.xml @@ -1256,16 +1256,28 @@ 0 0 - + - This setting enable notification when new admin user created. + This setting enables notification when new admin user is created. select 10 adminhtml/system_config_source_enabledisable 1 0 0 - + + + + Email address to receive notifications when a new admin user is created. Defaults to the General Store email address if empty. + 1 + text + validate-email + adminhtml/system_config_backend_email_addressorempty + 11 + 1 + 0 + 0 + The recommended value is 85, a higher value will increase the file size. You can set the value to 0 to disable image processing, but it may cause security risks. diff --git a/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.10-1.6.0.11.php b/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.10-1.6.0.11.php new file mode 100644 index 00000000000..995c66eff9f --- /dev/null +++ b/app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.10-1.6.0.11.php @@ -0,0 +1,41 @@ +startSetup(); + +$table = $installer->getTable('core/config_data'); + +if ($installer->getConnection()->isTableExists($table)) { + $oldPath = 'admin/security/crate_admin_user_notification'; + $newPath = 'admin/security/create_admin_user_notification'; + + $select = $installer->getConnection()->select() + ->from($table, ['config_id', 'path']) + ->where('path = ?', $oldPath); + + $rows = $installer->getConnection()->fetchAll($select); + + foreach ($rows as $row) { + $installer->getConnection()->update( + $table, + ['path' => $newPath], + ['config_id = ?' => $row['config_id']] + ); + } +} + +$installer->endSetup();