• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Notifications module - V2 alternatives? Sends email on event
PostPosted: Wed May 18, 2016 10:12 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Sat Apr 18, 2009 10:09 pm
Posts: 1243
Location: Maidenhead, UK
I use the notifications module on every V1 site. It's great, it notifies me by email every time an admin logs in to the backend. So I can easily see which clients are updating their sites - and which are not. It also emails me on every unsuccessful backend login (e.g. wrong password) so I can tell if someone, or something, is trying to hack in.

I would like to continue using it in V2 but it hasn't been updated in a while and it is unlikely to be updated because it was created by a couple of guys who have left the CMSMS world:
http://dev.cmsmadesimple.org/projects/notifications

I tried installing in to a V 2.1.3 site - it seemed to install without error but unsurprisingly it did not work, giving a white unstyled page when accessing the admin page.

Is there an alternative method of getting the functionality described without using this module?

Thanks

_________________
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... ps#phpinfo

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Notifications module - V2 alternatives? Sends email on e
PostPosted: Wed May 18, 2016 10:14 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 7215
Location: The Netherlands
Yep, a simple Mail UDT like http://docs.cmsmadesimple.org/general-i ... s#mail-udt


Ps. I also use it for http://www.cmscanbesimple.org/blog/mous ... ate-errors

_________________
Image

Did my post help you solving a problem at your (customers) website and it saved you many hours of work? Great!! Consider buying me a cup of coffee in return! [ Click here ]



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Notifications module - V2 alternatives? Sends email on e
PostPosted: Wed May 18, 2016 11:09 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Sat Apr 18, 2009 10:09 pm
Posts: 1243
Location: Maidenhead, UK
Thanks for the swift reply Rolf!

I tried the Mail UDT. It worked great. So I am now notified on a failed login.

I made a similar UDT and linked it to the LoginPost event, hoping to be told every time someone successfully logs in. The UDT fires OK but the $_POST["username"] field is blank. It would be great if anyone had some ideas on that.

_________________
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... ps#phpinfo

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Notifications module - V2 alternatives? Sends email on e
PostPosted: Thu May 19, 2016 7:07 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 7215
Location: The Netherlands
Code:
$_SESSION['login_user_username']

_________________
Image

Did my post help you solving a problem at your (customers) website and it saved you many hours of work? Great!! Consider buying me a cup of coffee in return! [ Click here ]



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Notifications module - V2 alternatives? Sends email on e
PostPosted: Thu May 19, 2016 8:23 am 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 2722
Location: The Netherlands
Quote:
LoginPost

Description: Sent after a user logs into the Admin panel
Parameters

'user' - Reference to the affected user object.

Event Handlers

None


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Notifications module - V2 alternatives? Sends email on e
PostPosted: Thu May 19, 2016 10:00 am 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 2722
Location: The Netherlands
Generic (for both failed en success):

Code:
$to = 'YOUREMAIL@YOURDOMAIN.COM';
$headers = 'From: CMS Made Simple website.com <noreply@website.com>';

$user = $params['user'];
if ($params['_eventname'] == 'LoginPost') {

$subject  = 'Successful login: ' . $user->username . ' - ' . cms_utils::get_real_ip();

$message_template  =<<<'EOD'
There has been a successful login in your admin panel.
Username: %s
IP Address: %s
First Name: %s
Last Name: %s
Email %s
EOD;

$message = sprintf($message_template,
  $user->username,
  cms_utils::get_real_ip(),
  $user->firstname,
  $user->lastname,
  $user->email
);
} elseif($params['_eventname'] == 'LoginFailed') {

$subject  = 'Failed login: ' . $user . ' - ' . cms_utils::get_real_ip();

$message_template  =<<<'EOD'
There has been a failed login in your admin panel.
Username: %s
IP Address: %s
EOD;

$message = sprintf($message_template,
  $user,
  cms_utils::get_real_ip()
);

}
@mail($to, $subject, $message, $headers);


Personally I'd rather use the CMSMS api to send the email out (instead of 'mail') but don't have time now to find out how.


Last edited by velden on Thu May 19, 2016 10:20 am, edited 1 time in total.
Removed 'Is Admin' from code


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Notifications module - V2 alternatives? Sends email on e
PostPosted: Thu May 19, 2016 2:08 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 7793
Location: Fernie British Columbia, Canada
in 2.x:

$mailer = new cms_mailer();
$mailer->SetSubject($subject);
$mailer->SetBody($body);
$mailer->AddAddress($email_address);
$mailer->Send();

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Notifications module - V2 alternatives? Sends email on e
PostPosted: Sun Oct 23, 2016 7:52 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Apr 23, 2008 7:53 am
Posts: 7215
Location: The Netherlands
Extended version of Veldens UDT
http://www.cmscanbesimple.org/blog/admi ... tification

_________________
Image

Did my post help you solving a problem at your (customers) website and it saved you many hours of work? Great!! Consider buying me a cup of coffee in return! [ Click here ]



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting