]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3955 removes public access from walled gardens - maintains groups functionality
authorCash Costello <cash.costello@gmail.com>
Mon, 2 Jul 2012 02:28:56 +0000 (22:28 -0400)
committerCash Costello <cash.costello@gmail.com>
Mon, 2 Jul 2012 02:28:56 +0000 (22:28 -0400)
engine/classes/ElggSite.php
engine/lib/elgglib.php

index e793ab9c6ed5be796ca879f8974b886f095d5370..401939005422343747fe6fdc04a6dad79947ea00 100644 (file)
@@ -381,14 +381,24 @@ class ElggSite extends ElggEntity {
        public function checkWalledGarden() {
                global $CONFIG;
 
-               if ($CONFIG->walled_garden && !elgg_is_logged_in()) {
-                       // hook into the index system call at the highest priority
-                       elgg_register_plugin_hook_handler('index', 'system', 'elgg_walled_garden_index', 1);
-
-                       if (!$this->isPublicPage()) {
-                               $_SESSION['last_forward_from'] = current_page_url();
-                               register_error(elgg_echo('loggedinrequired'));
-                               forward();
+               if ($CONFIG->walled_garden) {
+                       if ($CONFIG->default_access == ACCESS_PUBLIC) {
+                               $CONFIG->default_access = ACCESS_LOGGED_IN;
+                       }
+                       elgg_register_plugin_hook_handler(
+                                       'access:collections:write',
+                                       'user',
+                                       '_elgg_walled_garden_remove_public_access');
+
+                       if (!elgg_is_logged_in()) {
+                               // hook into the index system call at the highest priority
+                               elgg_register_plugin_hook_handler('index', 'system', 'elgg_walled_garden_index', 1);
+
+                               if (!$this->isPublicPage()) {
+                                       $_SESSION['last_forward_from'] = current_page_url();
+                                       register_error(elgg_echo('loggedinrequired'));
+                                       forward();
+                               }
                        }
                }
        }
index 0c42c1c083e1f6f317e9b90809ec6522e4d57507..3026a78e3d495fcc187617168042d78483056e7c 100644 (file)
@@ -2097,6 +2097,22 @@ function elgg_walled_garden() {
        }
 }
 
+/**
+ * Remove public access for walled gardens
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $accesses
+ * @return array
+ * @access private
+ */
+function _elgg_walled_garden_remove_public_access($hook, $type, $accesses) {
+       if (isset($accesses[ACCESS_PUBLIC])) {
+               unset($accesses[ACCESS_PUBLIC]);
+       }
+       return $accesses;
+}
+
 /**
  * Boots the engine
  *