+
+ /**
+ *
+ * We will always have a module name.
+ * First see if we have a plugin which is masquerading as a module.
+ *
+ */
+
+ // Compatibility with the Android Diaspora client
+ if ($a->module == "stream")
+ $a->module = "network";
+
+ $privateapps = get_config('config','private_addons');
+
+ if(is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
+ //Check if module is an app and if public access to apps is allowed or not
+ if((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
+ info( t("You must be logged in to use addons. "));
+ }
+ else {
+ include_once("addon/{$a->module}/{$a->module}.php");
+ if(function_exists($a->module . '_module'))
+ $a->module_loaded = true;
+ }
+ }
+
+ /**
+ * If not, next look for a 'standard' program module in the 'mod' directory
+ */
+
+ if((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
+ include_once("mod/{$a->module}.php");