I'm working on a module with the following objective:
Once a new Admin User Account is registered to the system an automated email should be sent to all Admin Users which have the
Administrators
role.
The purpose of this module is to automatically notify the Super Admin(s) that a new Admin User Account is added to the list of existing user accounts. I came up with this idea after reading this about signs of a compromised site. The module should flag unauthorized registration of Admin User Accounts.
I don't think there is such a feature available at the moment (correct me if I'm wrong). So I decided to try and create a module for this. I'm planning on making this module available for free in Magento Connect after it's finished. But since I'm not a hardcore backend developer I need some help to get there.
I want to hook to the admin_user_save_after
event because this event will be triggered when creating a new Admin User (or would it be possible for malicious users to bypass this event?)
I have my module registered and my config.xml file in place. Now I need to work on my Observer.php
file which is in the ../MyNamespace/MyModule/Model/
directory. But I'm not sure what code to put in my newAdminUserAlert
method.
Whenever the admin_user_save_after
event is triggered the method should:
- Check all existing Admin Users (that already existed before the
admin_user_save_after
event) - Check the User Role of those Admin Users
- Retrieve the email address(es) of all existing Admin Users who have the Administrators role assigned to them
- Send an email to those "Super Admins"
At least I think, this is the way to go.
This is what I have got so far:
<?php
class MyNamespace_MyModule_Model_Observer
{
public function newAdminUserAlert(Varien_Event_Observer $observer)
{
$adminUser = $observer->getEvent()->getObject();
}
}
I do understand that it's quite much that I'm asking, but I also believe this functionality would help in making Magento safer.
Any input regarding this topic is appreciated (also if you think this is a bad idea), especially if you could help me write the Observer.php
file.