send email on new account creation

This commit is contained in:
Antoine Beaupré 2009-01-29 00:54:52 +00:00
parent a7034d7779
commit d09637d0ce
3 changed files with 56 additions and 1 deletions

View File

@ -366,6 +366,55 @@ class m_admin {
} }
} }
/**
* AlternC's standard function called when a user is created
*
* This sends an email if configured through the interface.
*/
function alternc_add_member() {
global $cuid, $L_FQDN, $L_HOSTING;
$dest = variable_get('new_email');
if (!$dest) {
return false;
}
$db=new DB_System();
if (!$db->query("SELECT m.*, parent.login as parentlogin FROM membres m LEFT JOIN membres parent ON parent.uid=m.creator WHERE m.uid='$cuid'")) {
echo "query failed: " . $db->Error;
return false;
}
if ($db->next_record()) {
$mail = <<<EOF
A new AlternC account was created on %fqdn by %creator.
Account details
---------------
login: %login (%uid)
email: %mail
createor: %creator (%cuid)
can change password: %canpass
type: %type
notes: %notes
EOF;
$mail = strtr($mail, array('%fqdn' => $L_FQDN,
'%creator' => $db->Record['parentlogin'],
'%uid' => $db->Record['uid'],
'%login' => $db->Record['login'],
'%mail' => $db->Record['mail'],
'%cuid' => $db->Record['creator'],
'%canpass' => $db->Record['canpass'],
'%type' => $db->Record['type'],
'%notes' => $db->Record['notes']));
if (mail($dest,"New account on $L_HOSTING",$mail,"From: postmaster@$L_FQDN")) {
echo "Successfully sent email to $dest";
} else {
echo "Cannot send email to $dest";
}
} else {
echo "query failed: " . $db->Error;
}
}
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** /**
* Modifies an account * Modifies an account

4
debian/changelog vendored
View File

@ -14,8 +14,10 @@ alternc (0.9.10) unstable; urgency=low
* when adding a new domain to an account, a directory "www/example.net" * when adding a new domain to an account, a directory "www/example.net"
is automatically created and the domain points to it instead of /. is automatically created and the domain points to it instead of /.
* add new field to member form: 'notes' which is just a text field * add new field to member form: 'notes' which is just a text field
* send an email on new account creation. the actual email needs to be
configured through the AlternC variables for this to work.
-- Antoine Beaupré <anarcat@koumbit.org> Mon, 20 Oct 2008 16:12:28 -0400 -- Antoine Beaupré <anarcat@koumbit.org> Wed, 28 Jan 2009 19:52:46 -0500
alternc (0.9.9) stable; urgency=low alternc (0.9.9) stable; urgency=low

View File

@ -423,6 +423,10 @@ If this is set to 0 or a "false" string, it will be ignored.');
INSERT IGNORE INTO `variable` (name, value, comment) VALUES ('rss_feed', 0, INSERT IGNORE INTO `variable` (name, value, comment) VALUES ('rss_feed', 0,
'This is an RSS feed that will be displayed on the users homepages when 'This is an RSS feed that will be displayed on the users homepages when
they log in. Set this to 0 or a "false" string to ignore.'); they log in. Set this to 0 or a "false" string to ignore.');
INSERT IGNORE INTO `variable` (name, value, comment) VALUES ('new_email', 0,
'An email will be sent to this address when new accounts are created if set.');
-- --
-- Table structure for table `dbusers` -- Table structure for table `dbusers`
-- --