]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/statusnet.php
Corrected message in NoSuchGroupException
[quix0rs-gnu-social.git] / lib / statusnet.php
index cf2069c1a6114a9c378c6ad70896d97aa9d288d1..844a15c339d10cc8ab363ef296c366ccba1c5963 100644 (file)
@@ -44,7 +44,7 @@ class StatusNet
      *
      * @throws ServerException if plugin can't be found
      */
-    public static function addPlugin($name, $attrs = null)
+    public static function addPlugin($name, array $attrs=array())
     {
         $name = ucfirst($name);
 
@@ -78,11 +78,11 @@ class StatusNet
             }
         }
 
+        // Doesn't this $inst risk being garbage collected or something?
+        // TODO: put into a static array that makes sure $inst isn't lost.
         $inst = new $pluginclass();
-        if (!empty($attrs)) {
-            foreach ($attrs as $aname => $avalue) {
-                $inst->$aname = $avalue;
-            }
+        foreach ($attrs as $aname => $avalue) {
+            $inst->$aname = $avalue;
         }
 
         // Record activated plugins for later display/config dump
@@ -91,6 +91,20 @@ class StatusNet
         return true;
     }
 
+    public static function delPlugin($name)
+    {
+        // Remove our plugin if it was previously loaded
+        $name = ucfirst($name);
+        if (isset(self::$plugins[$name])) {
+            unset(self::$plugins[$name]);
+        }
+
+        // make sure initPlugins will avoid this
+        common_config_set('plugins', 'disable-'.$name, true);
+
+        return true;
+    }
+
     /**
      * Get a list of activated plugins in this process.
      * @return array of (string $name, array $args) pairs
@@ -205,6 +219,8 @@ class StatusNet
                 continue;
             }
 
+            // TODO: We should be able to avoid this is_null and assume $params
+            // is an array, since that's how it is typed in addPlugin
             if (is_null($params)) {
                 self::addPlugin($name);
             } else if (is_array($params)) {
@@ -327,7 +343,7 @@ class StatusNet
     {
         global $config;
         $settings = SiteProfile::getSettings($name);
-        $config = array_merge($config, $settings);
+        $config = array_replace_recursive($config, $settings);
     }
 
     protected static function _sn_to_path($sn)
@@ -407,11 +423,20 @@ class StatusNet
     static function isHTTPS()
     {
         // There are some exceptions to this; add them here!
-        if(empty($_SERVER['HTTPS'])) {
+        if (empty($_SERVER['HTTPS'])) {
             return false;
-        } else {
-            return $_SERVER['HTTPS'] !== 'off';
         }
+
+        // If it is _not_ "off", it is on, so "true".
+        return strtolower($_SERVER['HTTPS']) !== 'off';
+    }
+
+    /**
+     * Can we use HTTPS? Then do! Only return false if it's not configured ("never").
+     */
+    static function useHTTPS()
+    {
+        return self::isHTTPS() || common_config('site', 'ssl') != 'never';
     }
 }