diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php index e2b9e4ca..b18b84ba 100644 --- a/bureau/class/m_admin.php +++ b/bureau/class/m_admin.php @@ -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 = << $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 diff --git a/debian/changelog b/debian/changelog index 31b459bd..8fb474b9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,8 +14,10 @@ alternc (0.9.10) unstable; urgency=low * when adding a new domain to an account, a directory "www/example.net" is automatically created and the domain points to it instead of /. * 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é Mon, 20 Oct 2008 16:12:28 -0400 + -- Antoine Beaupré Wed, 28 Jan 2009 19:52:46 -0500 alternc (0.9.9) stable; urgency=low diff --git a/install/mysql.sql b/install/mysql.sql index e393bfe8..c740fafd 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -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, '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.'); + +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` --