aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-23 11:07:42 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-02-23 11:07:42 +0000
commit3cdf73acb6641827dda69599496384f33a8e0ffb (patch)
tree3f6afa425c4dd6e72feda6af79271ecf171ea66b /engine/lib
parenta0ff6865887915c866ec6e49ec5e13fbd0fb5eda (diff)
downloadelgg-3cdf73acb6641827dda69599496384f33a8e0ffb.tar.gz
elgg-3cdf73acb6641827dda69599496384f33a8e0ffb.tar.bz2
Introducing group_gatekeeper()
git-svn-id: https://code.elgg.org/elgg/trunk@2888 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/group.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/engine/lib/group.php b/engine/lib/group.php
index 588a60aac..cff387298 100644
--- a/engine/lib/group.php
+++ b/engine/lib/group.php
@@ -794,6 +794,36 @@
}
/**
+ * Checks access to a group.
+ *
+ * @param boolean $forward If set to true (default), will forward the page; if set to false, will return true or false.
+ * @return true|false If $forward is set to false.
+ */
+ function group_gatekeeper($forward = true) {
+
+ $allowed = true;
+ $url = '';
+
+ if ($group = page_owner_entity()) {
+ if ($group instanceof ElggGroup) {
+ $url = $group->getURL();
+ if (
+ ((!isloggedin()) && (!$group->isPublicMembership())) ||
+ ((!$group->isMember(get_loggedin_user()) && (!$group->isPublicMembership())))
+ ) $allowed = false;
+ }
+ }
+
+ if ($forward && $allowed == false) {
+ forward($url);
+ exit;
+ }
+
+ return $allowed;
+
+ }
+
+ /**
* Performs initialisation functions for groups
*
*/