]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
move email registration code to DomainStatusNetworkPlugin
authorEvan Prodromou <evan@status.net>
Mon, 6 Jun 2011 16:25:26 +0000 (12:25 -0400)
committerEvan Prodromou <evan@status.net>
Mon, 6 Jun 2011 16:25:26 +0000 (12:25 -0400)
plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php
plugins/DomainStatusNetwork/scripts/installforemail.php

index 9390a6e08353b3cdf441af4d9a3a5092251cbde2..68679f53bf39ea1a309213669bad2ff9edcda813 100644 (file)
@@ -195,6 +195,32 @@ class DomainStatusNetworkPlugin extends Plugin
                             _m('A plugin that maps a single status_network to an email domain.'));
         return true;
     }
+
+    static function registerEmail($email, $sendWelcome, $template)
+    {
+        $domain = self::toDomain($email);
+
+        $sn = self::siteForDomain($domain);
+
+        if (empty($sn)) {
+            $installer = new DomainStatusNetworkInstaller($domain);
+
+            // Do the thing
+            $installer->main();
+
+            $sn = $installer->getStatusNetwork();
+
+            $config = $installer->getConfig();
+
+            Status_network::$wildcard = $config['WILDCARD'];
+        }
+
+        StatusNet::switchSite($sn->nickname);
+
+        $confirm = EmailRegistrationPlugin::registerEmail($email);
+
+        return $confirm;
+    }
 }
 
 // The way addPlugin() works, this global variable gets disappeared.
index 98ce620c28cb24fcfa1fd50d7cf145eacaf32a8c..f773094a74c426e9ccc023b43468d08e5a61cef2 100644 (file)
@@ -39,39 +39,24 @@ require_once INSTALLDIR.'/scripts/commandline.inc';
 
 $email = $args[0];
 
-$domain = DomainStatusNetworkPlugin::toDomain($email);
+$sendWelcome = have_option('w', 'welcome');
 
-$sn = DomainStatusNetworkPlugin::siteForDomain($domain);
-
-if (empty($sn)) {
-    $installer = new DomainStatusNetworkInstaller($domain);
-
-    $installer->verbose = have_option('v', 'verbose');
-
-    // Do the thing
-    $installer->main();
-
-    $sn = $installer->getStatusNetwork();
-
-    $config = $installer->getConfig();
-
-    Status_network::$wildcard = $config['WILDCARD'];
+if ($sendWelcome && have_option('t', 'template')) {
+    $template = get_option_value('t', 'template');
 }
 
-StatusNet::switchSite($sn->nickname);
+try {
 
-$confirm = EmailRegistrationPlugin::registerEmail($email);
+    $confirm = DomainStatusNetworkPlugin::registerEmail($email);
 
-if (have_option('w', 'welcome')) {
-    if (have_option('t', 'template')) {
-        // use the provided template
-        EmailRegistrationPlugin::sendConfirmEmail($confirm, get_option_value('t', 'template'));
-    } else {
-        // use the default template
-        EmailRegistrationPlugin::sendConfirmEmail($confirm);
+    if ($sendWelcome) {
+        EmailRegistrationPlugin::sendConfirmEmail($confirm, $template);
     }
-}
 
-$confirmUrl = common_local_url('register', array('code' => $confirm->code));
+    $confirmUrl = common_local_url('register', array('code' => $confirm->code));
 
-print $confirmUrl."\n";
+    print $confirmUrl."\n";
+
+} catch (Exception $e) {
+    print "ERROR: " . $e->getMessage() . "\n";
+}