Page 3 of 3
Re: Use Events to Send an Email when a Page is Edited?
Posted: Tue Aug 14, 2007 3:30 pm
by cyberman
Maybe there's something wrong with your mail() function?
Re: Use Events to Send an Email when a Page is Edited?
Posted: Tue Aug 14, 2007 4:53 pm
by SimonSchaufi
no no. like i said before, when i change a page and send an email, IT WORKS!!! But when adding a new user, it doesnt work!
Re: Use Events to Send an Email when a Page is Edited?
Posted: Tue Aug 14, 2007 7:22 pm
by SimonSchaufi
IT WORKS!!!
My mistake was a dash in the UDT name:
send-mail
is not working (warum auch immer)
That is the reason why the other method with the cmsmailer was not working as well!
Re: Use Events to Send an Email when a Page is Edited?
Posted: Tue Aug 14, 2007 7:42 pm
by cyberman
SimonSchaufi wrote:
send-mail
is not working (warum auch immer)
You can read the reason here
http://forum.cmsmadesimple.org/index.ph ... 205.0.html
(in german)
Re: Use Events to Send an Email when a Page is Edited?
Posted: Tue Aug 14, 2007 8:06 pm
by SimonSchaufi
Here my solution (a bit tuned

):
Make sure you dont save it with a dash in the UDT name!
Code: Select all
function validate_email($email){
$exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
if(eregi($exp,$email)){
if(checkdnsrr(array_pop(explode("@",$email)),"MX")){
return true;
}else{
return false;
}
}else{
return false;
}
}
global $gCms;
$sitename = get_site_preference('sitename', 'My Homepage'); /* If sitename is not set, use My Homepage */
$newuser =& $params['user'];
$bodytext = 'This is your new user account information:
First Name: '.$newuser->firstname.'
Last Name: '.$newuser->lastname.'
Username: '.$newuser->username.'
Password: '.$_POST["password"].'
Email: '.$newuser->email.'
Login here: '.$gCms->config["root_url"].DIRECTORY_SEPARATOR.$gCms->config["admin_dir"].'
After login please change your password here: My Preferences -> My Account!';
if($newuser->email != "" && validate_email($newuser->email)){
$cmsmailer =& $gCms->modules['CMSMailer']['object'];
$cmsmailer->AddAddress($newuser->email);
$cmsmailer->SetBody($bodytext);
$cmsmailer->IsHTML(false);
$cmsmailer->SetSubject($sitename.' User Account Information');
$cmsmailer->Send();
}
There is no possibility to get the password as plain text so you need to catch it from the POST var.
If nobody has any other suggestions, i will post it in the wiki
Re: Use Events to Send an Email when a Page is Edited?
Posted: Sat Aug 18, 2007 8:25 pm
by calguy1000
When working with events, each event will return different items in $params. You have to check for this on a handler, by handler basis.
i.e: $params['content'] may not exist for every event, it may be something different, and even if it is..... it may not be a reference to an object, etc.
There is help for each event that describes what parameters are delivered (somewhat), and this would be a great place to start. After that, I'd start with:
print_r( $params ); die();
for every event handler, and then go from there.
Re: Use Events to Send an Email when a Page is Edited?
Posted: Sun Aug 19, 2007 12:49 am
by calguy1000
I just looked at the source, and a skilled module developer could write a module, using Events to add versioning into CMS Made Simple. It's a very nice system, the Events give CMS Made simple an extreme amount of flexibility and customising capability with just a bit of programming knowledge.
Re: Use Events to Send an Email when a Page is Edited?
Posted: Fri Nov 30, 2007 9:00 am
by OCStingFan
How could this code (i.e the UDT in the wiki called "Send Email Notification on Page Change") be set up to send a notification to a dynamic group of recipients rather than an individual or unchanging group of recipients? I'm developing a site now for a school and the teachers will have their own pages to post notes for parents to check. An existing web-based solution which I am trying to emulate in the CMS allows the teacher to send a notification when their page is updated to the parents' email addresses. If a mailing list can be set up inside CMSMS (such as in the NMS module), can that be a basis for sending an email notification using Events?
Re: Use Events to Send an Email when a Page is Edited?
Posted: Mon Dec 03, 2007 11:32 am
by cyberman
Maybe you should use FrontendUsers module?
It has an own event if user data are changed ...