aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-01-31 01:29:24 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-01-31 01:29:24 +0000
commit39fb85265f4e22ff2f87633d2347cecb233e65e5 (patch)
tree6019fa420aa014874c35747c5ef765eb4cb3477a
parente3d22584664b28d31aa138f7b82554694254aae2 (diff)
downloadelgg-39fb85265f4e22ff2f87633d2347cecb233e65e5.tar.gz
elgg-39fb85265f4e22ff2f87633d2347cecb233e65e5.tar.bz2
Fixes #804: A relationship is created between a new user and the site it was created on.
git-svn-id: http://code.elgg.org/elgg/trunk@3867 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/users.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 0171e838d..341024a45 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -76,7 +76,7 @@ class ElggUser extends ElggEntity
// Is $guid is an ElggUser? Use a copy constructor
else if ($guid instanceof ElggUser) {
elgg_log('This type of usage of the ElggUser constructor was deprecated in 1.7. Please use the clone method.', 'WARNING');
-
+
foreach ($guid->attributes as $key => $value) {
$this->attributes[$key] = $value;
}
@@ -1446,6 +1446,20 @@ function new_user_enable_permissions_check($hook, $entity_type, $returnvalue, $p
}
/**
+ * Creates a relationship between this site and the user.
+ *
+ * @param $event
+ * @param $object_type
+ * @param $object
+ * @return bool
+ */
+function user_create_hook_add_site_relationship($event, $object_type, $object) {
+ global $CONFIG;
+
+ add_entity_relationship($object->getGUID(), 'member_of_site', $CONFIG->site->getGUID());
+}
+
+/**
* Sets up user-related menu items
*
*/
@@ -1517,6 +1531,8 @@ function users_init() {
register_plugin_hook('usersettings:save','user','users_settings_save');
+ register_elgg_event_handler('create', 'user', 'user_create_hook_add_site_relationship');
+
// Handle a special case for newly created users when the user is not logged in
// TODO: handle this better!
register_plugin_hook('permissions_check','all','new_user_enable_permissions_check');