]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/EmailRegistration/EmailRegistrationPlugin.php
Merge branch 'master' of gitorious.org:social/mainline into social-master
[quix0rs-gnu-social.git] / plugins / EmailRegistration / EmailRegistrationPlugin.php
index 548702514a1dccd49fd7588fc02357a1722d7112..9e0fd58856758894884d2692ee409de6e2c19f51 100644 (file)
@@ -49,24 +49,6 @@ class EmailRegistrationPlugin extends Plugin
 {
     const CONFIRMTYPE = 'register';
 
-    function onAutoload($cls)
-    {
-        $dir = dirname(__FILE__);
-
-        switch ($cls)
-        {
-        case 'EmailregisterAction':
-            include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
-            return false;
-        case 'EmailRegistrationForm':
-        case 'ConfirmRegistrationForm':
-            include_once $dir . '/' . strtolower($cls) . '.php';
-            return false;
-        default:
-            return true;
-        }
-    }
-
     function onArgsInitialize(&$args)
     {
         if (array_key_exists('action', $args) && $args['action'] == 'register') {
@@ -102,7 +84,7 @@ class EmailRegistrationPlugin extends Plugin
 
     static function registerEmail($email)
     {
-        $old = User::staticGet('email', $email);
+        $old = User::getKV('email', $email);
 
         if (!empty($old)) {
             // TRANS: Error text when trying to register with an already registered e-mail address.
@@ -147,7 +129,7 @@ class EmailRegistrationPlugin extends Plugin
 
         $n = 0;
 
-        while (User::staticGet('nickname', $nickname)) {
+        while (User::getKV('nickname', $nickname)) {
             $n++;
             $nickname = $original . $n;
         }
@@ -155,7 +137,7 @@ class EmailRegistrationPlugin extends Plugin
         return $nickname;
     }
 
-    static function sendConfirmEmail($confirm)
+    static function sendConfirmEmail($confirm, $title=null)
     {
         $sitename = common_config('site', 'name');
 
@@ -165,29 +147,35 @@ class EmailRegistrationPlugin extends Plugin
         $headers['To'] = trim($confirm->address);
          // TRANS: Subject for confirmation e-mail.
          // TRANS: %s is the StatusNet sitename.
-        $headers['Subject'] = sprintf(_m('Confirm your registration on %s'), $sitename);
+        $headers['Subject'] = sprintf(_m('Welcome to %s'), $sitename);
+        $headers['Content-Type'] = 'text/html; charset=UTF-8';
 
         $confirmUrl = common_local_url('register', array('code' => $confirm->code));
 
-         // TRANS: Body for confirmation e-mail.
-         // TRANS: %1$s is the StatusNet sitename, %2$s is the confirmation URL.
-        $body = sprintf(_m('Someone (probably you) has requested an account on %1$s using this email address.'.
-                          "\n".
-                          'To confirm the address, click the following URL or copy it into the address bar of your browser.'.
-                          "\n".
-                          '%2$s'.
-                          "\n".
-                          'If it was not you, you can safely ignore this message.'),
-                        $sitename,
-                        $confirmUrl);
+        if (empty($title)) {
+            $title = 'confirmemailreg';
+        }
+
+        $confirmTemplate = DocFile::forTitle($title, DocFile::mailPaths());
+
+        $body = $confirmTemplate->toHTML(array('confirmurl' => $confirmUrl));
 
         mail_send($recipients, $headers, $body);
     }
 
-    function onPluginVersion(&$versions)
+    function onEndDocFileForTitle($title, $paths, &$filename)
+    {
+        if ($title == 'confirmemailreg' && empty($filename)) {
+            $filename = dirname(__FILE__).'/mail-src/'.$title;
+            return false;
+        }
+        return true;
+    }
+
+    function onPluginVersion(array &$versions)
     {
         $versions[] = array('name' => 'EmailRegistration',
-                            'version' => STATUSNET_VERSION,
+                            'version' => GNUSOCIAL_VERSION,
                             'author' => 'Evan Prodromou',
                             'homepage' => 'http://status.net/wiki/Plugin:EmailRegistration',
                             'rawdescription' =>