]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/DomainWhitelist/DomainWhitelistPlugin.php
plugins onAutoload now only overloads if necessary (extlibs etc.)
[quix0rs-gnu-social.git] / plugins / DomainWhitelist / DomainWhitelistPlugin.php
index e320fb2490731babaab6a6714e0c7e76454dc1df..9aa67ab8450d32d08ee9c7ebfd6db2f8acc7c3d5 100644 (file)
@@ -48,32 +48,6 @@ if (!defined('STATUSNET')) {
  */
 class DomainWhitelistPlugin extends Plugin
 {
-    /**
-     * Load related modules when needed
-     *
-     * @param string $cls Name of the class to be loaded
-     *
-     * @return boolean hook value; true means continue processing, false
-     *         means stop.
-     */
-    function onAutoload($cls) {
-        $base = dirname(__FILE__);
-        $lower = strtolower($cls);
-
-        $files = array("$base/classes/$cls.php",
-            "$base/lib/$lower.php");
-        if (substr($lower, -6) == 'action') {
-            $files[] = "$base/actions/" . substr($lower, 0, -6) . ".php";
-        }
-        foreach ($files as $file) {
-            if (file_exists($file)) {
-                include_once $file;
-                return false;
-            }
-        }
-        return true;
-    }
-
     /**
      * Get the path to the plugin's installation directory. Used
      * to link in js files and whatnot.
@@ -118,7 +92,7 @@ class DomainWhitelistPlugin extends Plugin
                 } else {
                     // TRANS: Client exception thrown when a given e-mailaddress is not in the domain whitelist.
                     // TRANS: %s are whitelisted e-mail domains separated by comma's (localisable).
-                    $message = sprintf(_('Email address must be in one of these domains: %s.'),
+                    $message = sprintf(_m('Email address must be in one of these domains: %s.'),
                                        // TRANS: Separator for whitelisted domains.
                                        implode(_m('SEPARATOR',', '), $whitelist));
                 }
@@ -132,7 +106,7 @@ class DomainWhitelistPlugin extends Plugin
     {
         if (!$this->matchesWhitelist($email)) {
             // TRANS: Exception thrown when an e-mail address does not match the site's domain whitelist.
-            throw new Exception(_('That email address is not allowed on this site.'));
+            throw new Exception(_m('That email address is not allowed on this site.'));
         }
 
         return true;
@@ -231,8 +205,9 @@ class DomainWhitelistPlugin extends Plugin
                 )
             );
 
-            array_unshift($orderedWhitelist, $userDomain);
-
+            if (in_array($userDomain, $whitelist)) {
+                array_unshift($orderedWhitelist, $userDomain);
+            }
             return $orderedWhitelist;
         }
 
@@ -248,11 +223,25 @@ class DomainWhitelistPlugin extends Plugin
      */
     function onStartShowInviteForm($action)
     {
+        $this->showConfirmDialog($action);
         $form = new WhitelistInviteForm($action, $this->getWhitelist());
         $form->show();
         return false;
     }
 
+    function showConfirmDialog($action)
+    {
+        // For JQuery UI modal dialog
+        $action->elementStart(
+            'div',
+            // TRANS: Title for invitiation deletion dialog.
+            array('id' => 'confirm-dialog', 'title' => _m('Confirmation Required'))
+        );
+        // TRANS: Confirmation text for invitation deletion dialog.
+        $action->text(_m('Really delete this invitation?'));
+        $action->elementEnd('div');
+    }
+
     /**
      * This is a bit of a hack. We take the values from the custom
      * whitelist invite form and reformat them so they look like